Repository navigation
fix(server): correct raw file download responses - #4800
Conversation
🦋 Changeset detectedLatest commit: f8b7c67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06e41566ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
06e4156 to
6ff3259
Compare
|
@codex review |
6ff3259 to
f496ec7
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f496ec70d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
f496ec7 to
77d9791
Compare
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77d9791664
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
77d9791 to
6e1736f
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
6e1736f to
f8b7c67
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Requirement or Bug
文件预览或下载失败时,
/fs:content与 session:download会把 HTTP 200 的 JSON 错误 envelope 当成文件内容返回。上传附件与 session media 的另一条响应头路径还会丢弃非 ASCII 文件名。本 PR 修正原始文件响应的错误状态,并让这些路由统一保留 Unicode 文件名。关联反馈:
53825081-cba9-41e9-88a6-2388b086e6fe。该记录包含两个案例;本 PR 处理其中有 HTTP 200 错误 envelope 证据的机制,不把首条无文件名证据的案例强行归为同一根因。Bug Reproduction Steps
/api/v1/fs:content?path=/missing.png或/api/v1/sessions/:id/fs/missing.png:download。application/json和code=40409,原始文件客户端会把它当成 PNG 内容。/files/:id或 session media。Content-Disposition只有inline或attachment,原始文件名丢失。Root Cause
两条原始文件路由复用了普通 JSON RPC 的
reply.send(errEnvelope(...)),没有设置 HTTP 错误状态。普通 JSON RPC 的 HTTP 200 envelope 是既有契约,但原始文件客户端以 HTTP 状态区分文件和错误,因此同一响应在文件路由中会被误读。buildContentDisposition只为受限 ASCII 文件名输出filename,其他名字直接省略。/fs已在 #4563 中实现 ASCII fallback + RFC 5987filename*,但上传与 session media 未共享该行为。Code Changes
/fs:content和 session:download,普通 JSON RPC 仍返回 HTTP 200 envelope。CONFIG_INVALID保留40001/HTTP 400,其他未映射错误返回 HTTP 500,不再落回全局 HTTP 200。Content-Disposition。纯 ASCII 普通文件名保持原行为;引号和反斜杠安全转义;CR/LF 不进入普通filename;原始名称以filename*保留。filename*并将 ASCII fallback 限制为 256 字符。先截断再转义,避免长 Unicode 名称使响应头超限或截断引号、反斜杠转义对。server-api.md同步描述这两条原始下载路由的 400、403、404、409、413、500 JSON 错误响应。Behavior Changes and Affected Users
/fs:content失败:download失败codefilenamefilename*,原始文件字节不变/fs成功下载filename*,ASCII fallback 截为 256 字符验证:
f8b7c67a7;CI 全绿(test-windows按条件跳过),Codex completed,未决线程 0。11d9fda8e(已包含 test(server): cover download filename edge cases #4790 的完整文件名测试矩阵,并已 rebase 到当前 main)。code40409,UI 显示真实错误,不再显示 JSON 或破图;上传 PNG 在两端真实渲染,PDF/PNG 响应字节与源文件一致。6e1736f76的快速复核 6/6 通过:正常中文 PNG 两端真实渲染,工作区与外部缺失均返回 404 +code40409,UI 分别显示项目内未找到与文件不存在。随后仅 rebase 到11d9fda8e,运行时代码未再变化。Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.