mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 12:50:37 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Board users can open and download files from a task's workspace through the file-resources route > - The download response builds a raw `Content-Disposition` header from the file name > - Node rejects header values that hold characters outside Latin-1, such as the U+202F narrow no-break space in macOS screenshot names, or CJK text > - The route then fails with `TypeError: Invalid character in header content ["Content-Disposition"]` and returns 500 > - This pull request makes the route use `res.attachment()`, which encodes the name correctly > - The benefit is that users can download workspace files with any name ## Linked Issues or Issue Description Refs #22892. That PR fixes the same defect in the asset and invite-logo routes. This PR fixes the last route that builds the header by hand: the workspace file download. The two PRs change different files and do not conflict. **What happened?** A staging server reported `TypeError: Invalid character in header content ["Content-Disposition"]` from `ServerResponse.setHeader`. A workspace file download with a non-Latin-1 file name returns HTTP 500 for the same reason. **Expected behavior** The download succeeds. The header holds an ASCII `filename` fallback and an RFC 6266 `filename*` parameter with the full UTF-8 name. **Steps to reproduce** 1. Put a file named `Screenshot 10.32.55 PM.png` (with U+202F before `PM`) in a project workspace. 2. Download it through `GET /api/issues/:issueId/file-resources/content?download=1`. 3. The server returns 500. **Relevant logs or output** `TypeError: Invalid character in header content ["Content-Disposition"]` at `ServerResponse.setHeader (node:_http_outgoing)`. ## What Changed - `server/src/routes/file-resources.ts`: the download path now calls `res.attachment(safeAttachmentFilename(title))` instead of writing the raw header. The call comes before `Content-Type`, so the route keeps its own content type. - `server/src/__tests__/file-resources.test.ts`: a new test downloads a file whose name holds U+202F and Japanese text. It checks the status, the content type, the encoded `Content-Disposition`, and the bytes. ## Verification - Red: without the route change, `npx vitest run src/__tests__/file-resources.test.ts -t "not Latin-1"` fails with `expected 500 to be 200`. - Green: with the change, `npx vitest run src/__tests__/file-resources.test.ts` passes (53 of 53). The old `archive.bin` and `index.html` download tests still get `attachment; filename="..."` unchanged. - I also reproduced the Node error directly: `setHeader("Content-Disposition", 'inline; filename="Screenshot 10.32.55 PM.png"')` throws the same message. ## Risks Low risk. ASCII file names produce the same header as before. Non-Latin-1 names now get a `?` fallback in `filename` and the full name in `filename*`, which current browsers use. `res.attachment()` also sets `Content-Type` from the extension, but the route sets its own value right after that call. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), used as an agent with tool use (shell, code edits, test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>