Repository navigation
fix(feishu): preserve local attachment filenames in message send flow - #43239
PPFruitClaw wants to merge 8 commits into
Conversation
Greptile SummaryThis PR threads an explicit Key issues found:
Confidence Score: 2/5
|
| @@ -264,12 +246,10 @@ export async function uploadFileFeishu(params: { | |||
| // See: https://github.com/larksuite/node-sdk/issues/121 | |||
There was a problem hiding this comment.
Removed filename sanitization may cause silent upload failures with non-ASCII names
sanitizeFileNameForUpload was removed entirely. The original JSDoc explicitly documented the reason for its existence:
Non-ASCII characters (Chinese, em-dash, full-width brackets, etc.) cause the upload to silently fail when passed raw through the SDK's form-data serialization. RFC 5987 percent-encoding keeps headers 7-bit clean while Feishu's server decodes and preserves the original display name.
The PR now passes filenames like "测试文件.md" directly to client.im.file.create. If the underlying node-sdk / form-data serialization has not been updated to handle multi-byte characters, uploads with non-ASCII filenames will silently fail (no error thrown, just a missing file on the Feishu side).
Because the PR description notes "not run" for testing, please verify this against an actual Feishu environment with a non-ASCII filename before removing the sanitization. If the SDK now handles it correctly, a code comment explaining that change would help future maintainers understand why the encoding step is no longer needed.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/media.ts
Line: 246
Comment:
**Removed filename sanitization may cause silent upload failures with non-ASCII names**
`sanitizeFileNameForUpload` was removed entirely. The original JSDoc explicitly documented the reason for its existence:
> Non-ASCII characters (Chinese, em-dash, full-width brackets, etc.) cause the upload to **silently fail** when passed raw through the SDK's form-data serialization. RFC 5987 percent-encoding keeps headers 7-bit clean while Feishu's server decodes and preserves the original display name.
The PR now passes filenames like `"测试文件.md"` directly to `client.im.file.create`. If the underlying `node-sdk` / `form-data` serialization has not been updated to handle multi-byte characters, uploads with non-ASCII filenames will silently fail (no error thrown, just a missing file on the Feishu side).
Because the PR description notes **"not run"** for testing, please verify this against an actual Feishu environment with a non-ASCII filename before removing the sanitization. If the SDK now handles it correctly, a code comment explaining that change would help future maintainers understand why the encoding step is no longer needed.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28e1972b30
ℹ️ 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".
| const uploadSource = mediaUrl && !mediaBuffer ? mediaUrl : buffer!; | ||
| const { fileKey } = await uploadFileFeishu({ | ||
| cfg, | ||
| file: buffer, | ||
| file: uploadSource, |
There was a problem hiding this comment.
Download URL media before creating upload stream
sendMediaFeishu now forwards mediaUrl directly to uploadFileFeishu for every non-image branch, but uploadFileFeishu treats any string as a filesystem path (fs.createReadStream). For https://..., file://..., or signed URLs with query strings, this creates an invalid local stream and the upload fails, so Feishu file/document sends from URLs (and image URLs without a recognized extension) regress from working to runtime failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 699d2605e0
ℹ️ 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".
| const uploadSource = mediaUrl && !mediaBuffer ? mediaUrl : buffer!; | ||
| const { fileKey } = await uploadFileFeishu({ | ||
| cfg, | ||
| file: buffer, | ||
| file: uploadSource, |
There was a problem hiding this comment.
Apply local-root validation to non-image Feishu uploads
This branch now bypasses loadWebMedia(...localRoots...) for non-image mediaUrl values and forwards the raw string directly to uploadFileFeishu, which opens it with fs.createReadStream; that means a caller can upload arbitrary local files (for example /etc/passwd) even when mediaLocalRoots should block paths outside allowed roots. The previous path validation/hardening is therefore skipped for non-image sends, so local media should be validated/read through the guarded loader before creating the upload stream.
Useful? React with 👍 / 👎.
699d260 to
f60721e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f60721e2a7
ℹ️ 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".
| @@ -1,54 +0,0 @@ | |||
| # Protect the ownership rules themselves. | |||
There was a problem hiding this comment.
Reinstate CODEOWNERS protections
Removing .github/CODEOWNERS drops required ownership review for sensitive surfaces (security code, CodeQL workflow, release scripts/docs), so future PRs can merge those changes without the designated secops/release-manager reviewers; this materially weakens repository safety controls and does not align with the Feishu-focused scope of this commit.
Useful? React with 👍 / 👎.
| if (isLocalPath && !isImage) { | ||
| const fileType = detectFileType(effectiveFileName); | ||
| const { fileKey } = await uploadFileFeishu({ | ||
| cfg, | ||
| file: mediaUrl, |
There was a problem hiding this comment.
Enforce local-root checks in Feishu local upload fast path
This new fast path uploads absolute non-image mediaUrl values directly from disk via uploadFileFeishu and never validates against mediaLocalRoots, so a crafted send request can exfiltrate arbitrary local files (for example /etc/passwd) instead of being constrained to allowed roots; this occurs whenever mediaUrl is absolute and extension-derived isImage is false.
Useful? React with 👍 / 👎.
| data: { | ||
| file_type: fileType, | ||
| file_name: safeFileName, | ||
| file_name: fileName, |
There was a problem hiding this comment.
Sanitize filename before Feishu multipart upload
uploadFileFeishu now forwards raw fileName into file_name, but filenames can come from payload overrides and may contain control characters or quote/backslash sequences; without applying sanitizeFileNameForUpload, multipart headers can be malformed or rejected for those inputs, regressing the hardening this module already defines for upload safety.
Useful? React with 👍 / 👎.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I did a careful shell check against current Current main already contains the useful filename-preservation path for outbound attachment sends, including focused buffer/filename hydration and gateway delivery tests, while this older PR still carries broad unrelated artifacts plus Feishu delivery and security regressions. Closing the stale branch is safer than keeping it as a landing candidate. So I’m closing this older PR as already covered on Review detailsBest possible solution: Keep the current-main implementation and close this stale branch; any remaining Feishu display-name work should arrive as a narrow PR on top of the guarded loader and existing filename tests. Do we have a high-confidence way to reproduce the issue? Yes for the PR-introduced problems: source inspection shows the branch bypasses mediaLocalRoots and can route remote non-image URLs into fs.createReadStream. I did not run live Feishu delivery, so the branch's intended display-name improvement still lacks real-environment proof. Is this the best way to solve the issue? No. Current main implements the useful filename/attachment path with narrower shared outbound changes and tests; this branch is too broad and risky to be the best fix. Security review: Security review needs attention: The PR diff raises concrete security and supply-chain concerns by bypassing Feishu local-root checks, deleting CODEOWNERS, and weakening filename upload hardening.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against b3128ba93def; fix evidence: release v2026.6.5-beta.3, commit 6a0fdea90ad0. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
filenamevalues through the outbound send pipeline so Feishu adapters can honor caller-provided namesNotes
Testing