Skip to content

Long session titles produce unsavable export filenames #54721

Closed

Description

@kpdagrt22

Description

sessionExportFilename in packages/app/src/session/commands/export.ts has no length cap, so a long session title produces a filename over the 255-byte filesystem component limit and the export cannot be saved.

Version

2.0.27

Reproduction

Call sessionExportFilename with a 300-character title on current dev. The returned name is over 255 bytes before the .json extension handling.

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the report. I reproduced this on 2.0.27, and it still happens on the latest dev (773d862).

    Calling sessionExportFilename with a 300-character title returns a 305-byte name (aaa…a.json). Writing a file with that name fails with ENAMETOOLONG: name too long. The function cleans up the title but never limits its length. The script below reproduces it.

    Your open PR #54726 is the related fix for v2. #49142 was the earlier report of the same problem on v1.

    Reproduction script (repro.ts)
    // Reproduces #54721: sessionExportFilename has no length cap.
    // Usage: bun /workspace/repro/repro.ts [path/to/packages/app/src/session/commands/export.ts]
    // Default: /workspace/repo checkout. For v2.0.27: git show v2.0.27:packages/app/src/session/commands/export.ts > /tmp/opencode/v27/export.ts
    import { mkdirSync, writeFileSync, rmSync } from "node:fs"
    import { join } from "node:path"
    
    const path = process.argv[2] ?? "/workspace/repo/packages/app/src/session/commands/export.ts"
    const { sessionExportFilename } = await import(path)
    
    const name: string = sessionExportFilename({ id: "ses_test", title: "a".repeat(300) })
    const bytes = Buffer.byteLength(name)
    console.log(`source: ${path}`)
    console.log(`filename length: ${bytes} bytes (limit 255)`)
    
    const dir = "/tmp/opencode/export-test"
    mkdirSync(dir, { recursive: true })
    try {
      writeFileSync(join(dir, name), "{}")
      console.log("write: OK")
    } catch (e: any) {
      console.log(`write failed: ${e.code} ${e.message}`)
    } finally {
      rmSync(dir, { recursive: true, force: true })
    }
    process.exit(bytes > 255 ? 1 : 0)

    Run it: bun repro.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions