Skip to content

Keep Download all file names within the 255-byte limit - #435

Open
officialasishkumar wants to merge 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/bundle-name-byte-limit
Open

officialasishkumar wants to merge 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/bundle-name-byte-limit

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

By opening this pull request you agree to the Contributor License Agreement. On your first pull request a bot asks you to sign it with a one-line comment.

Fixes #403

Artifact names are capped at 180 characters, but most file systems cap one file name at 255 bytes, and a character outside ASCII takes up to 4 bytes in UTF-8. buildArtifactBundle kept the name as it was, so a file named with 176 Chinese characters plus .txt became a 532-byte ZIP entry, which an unzip tool may refuse or shorten on its own.

What changed

All code changes are in packages/artifact-formats/src/index.ts:

  • Each entry name is shortened to 255 UTF-8 bytes. The cut lands between characters, never inside one.
  • The extension is kept. A copy suffix such as (2) is fitted first and the rest of the name is cut to make room, so two names that shorten to the same text still get two different entries. Real names are still reserved before any suffix is given out, as in Keep every file in Download all when names collide #400.
  • An extension too long to keep next to a copy suffix (more than 223 bytes) is treated as part of the name, so the suffix always fits.
  • Names already within 255 bytes are unchanged.
  • The package README now mentions the limit.

Tests

Five new cases in packages/artifact-formats/test/formats.test.ts:

  • 176 three-byte characters plus .txt becomes 83 characters plus .txt (253 bytes)
  • a cut that would land inside a four-byte emoji drops the whole emoji
  • three names that share their first 170 characters become 名×83.pdf, 名×82 (2).pdf and 名×82 (3).pdf, all within 255 bytes
  • a name whose "extension" is 300 bytes is cut as one name, and its copy still gets a (2) within the limit
  • a name of exactly 255 bytes is left as it is

The first four fail on main.

End to end, I published two files through artifact_publish on one run (文×176.txt and 文×175字.txt, which are different names that shorten to the same text) and fetched the real GET /api/artifacts/runs/:runId/archive route. Reading the name lengths straight from the ZIP's central directory:

Entry names
Before 532 and 532 bytes
After 文×83.txt (253 bytes), 文×82 (2).txt (254 bytes)

This change has no visible UI, so the table is the before and after. The Download all button itself was not clicked in a browser.

Checks with Bun 1.3.14:

  • cd packages/artifact-formats && bun run test: 42 pass, 0 fail
  • cd packages/artifact-formats && bunx -p typescript@5.9.3 tsc --noEmit: passes
  • cd backend && bun test test/artifacts.test.ts (against pgvector/pgvector:0.8.6-pg16-bookworm, with the package reinstalled): 40 pass, 0 fail
  • bun test scripts/agent-docs.test.ts: 5 pass

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Artifact names are capped at 180 characters, but most file systems cap a
single file name at 255 bytes, and a character outside ASCII takes up to 4
bytes in UTF-8. A name of 176 Chinese characters plus ".txt" became a
532-byte ZIP entry, which unzip tools may refuse or shorten on their own.

buildArtifactBundle now shortens each entry name to 255 UTF-8 bytes:

- the cut lands between characters, never inside one;
- the extension is kept, and so is a " (2)" style copy suffix, which is
  fitted before the stem is cut, so two names that shorten to the same
  text still get different entries;
- an extension too long to keep beside a copy suffix is treated as part
  of the name, so the suffix always fits.

Names already within the limit are unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep Download all file names within the 255-byte limit

1 participant