Skip to content

fix(trueforge-ui): encode artifact paths in download links - #686

Open
CaptainAni187 wants to merge 1 commit into
truefoundry:mainfrom
CaptainAni187:fix-artifact-download-url-encoding
Open

fix(trueforge-ui): encode artifact paths in download links#686
CaptainAni187 wants to merge 1 commit into
truefoundry:mainfrom
CaptainAni187:fix-artifact-download-url-encoding

Conversation

@CaptainAni187

@CaptainAni187 CaptainAni187 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Artifact paths come from the model's sandbox_artifacts fence and were concatenated into the download href unencoded, so a generated name containing a space, #, ?, & or % produced a broken or misparsed URL. # in particular silently truncates the rest.

Closes #424

Changes

  • Encode each segment of the path in ChatFileDownload, so / keeps its structural meaning and everything else is escaped
  • Test covering spaces, #, &, ?, % and non-ASCII names

Worth flagging: not encodeURIComponent(path) as the issue suggests. fileDownloadBaseUrl is a path prefix, not a ?path= query, so encoding the whole string turns /report.pdf into %2Freport.pdf and breaks the links the existing test pins.

How was this tested?

vitest run test/atoms/ChatFileDownload.test.tsx in packages/trueforge-ui — 5 pass. Reverting only the encode call fails the new case and leaves the other four green.

Checklist

  • I have read the contributing guidelines
  • format:check passes repo-wide and eslint is clean on the touched files; ran the package's own tests rather than the full pnpm test. Repo-wide lint:ci has 55 pre-existing errors, all in packages/frontend/* and DropdownMenu.tsx, none in files this PR touches
  • Tests added/updated where it makes sense
  • No hand-edits to generated code
  • Docs / .env.example — not applicable

Changeset included. On process: CONTRIBUTING asks for approval first, and all six help wanted issues are assigned or already have PRs, so there was nothing approved to pick up. Close this if you'd rather it went through the queue.

Artifact paths come from the model's sandbox_artifacts fence, so a generated
file name can contain characters that change what the URL means: a space or %
breaks the request, # silently truncates it, and ?/& inject query parameters.
The href was built by raw concatenation, so those reached the anchor verbatim.

Encode each path segment, which leaves / doing its structural job and escapes
everything else. Percent-encoding a path segment is what the server already
expects, so existing links are unaffected.

Fixes truefoundry#424
@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5a9b686

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

trueforge-ui ChatFileDownload builds href by concatenating model-controlled artifact paths without URL-encoding

1 participant