fix(im): preserve original URL filename for uploaded file messages#514
fix(im): preserve original URL filename for uploaded file messages#514
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughFilename preservation added: mediaBuffer now stores an original Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mediaBuffer.FileName() returned a hardcoded "media"+ext, so IM file messages sent via URL displayed generic names like "media.pdf" instead of the filename parsed from the URL. This regressed the pre-refactor tempfile path which at least carried a unique basename. Store fileNameFromURL(rawURL) on the buffer and return it from FileName(). Split newMediaBuffer so the URL-to-filename wiring is reachable from tests without going through the hardened download transport. Also lock in that the local upload branch keeps filepath.Base(filePath) as file_name, so the URL fix cannot silently regress the local branch later. Change-Id: I729b217e9dc9237aeb89c2b89df86a37ad64a840
89ef7ec to
9962675
Compare
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@9962675cc186f2e35b8d5fea4e1a1e7fae0476ad🧩 Skill updatenpx skills add larksuite/cli#fix/im-url-filename -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #514 +/- ##
=======================================
Coverage 59.05% 59.06%
=======================================
Files 384 384
Lines 32632 32634 +2
=======================================
+ Hits 19270 19274 +4
+ Misses 11553 11551 -2
Partials 1809 1809 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…arksuite#514) mediaBuffer.FileName() returned a hardcoded "media"+ext, so IM file messages sent via URL displayed generic names like "media.pdf" instead of the filename parsed from the URL. This regressed the pre-refactor tempfile path which at least carried a unique basename. Store fileNameFromURL(rawURL) on the buffer and return it from FileName(). Split newMediaBuffer so the URL-to-filename wiring is reachable from tests without going through the hardened download transport. Also lock in that the local upload branch keeps filepath.Base(filePath) as file_name, so the URL fix cannot silently regress the local branch later. Change-Id: I729b217e9dc9237aeb89c2b89df86a37ad64a840
Summary
mediaBuffer.FileName()was hardcoded to"media" + ext, so IM file messages sent via URL displayed generic names likemedia.pdfinstead of the filename parsed from the URL. The refactor that introducedmediaBufferinadvertently threw away the basename thatfileNameFromURL(rawURL)already provided.fileNameFromURL(rawURL)on the buffer and return it fromFileName(). SplitnewMediaBufferso the URL-to-filename wiring is reachable from tests without going through the hardened download transport.filepath.Base(filePath)stays thefile_namefield, so a future consolidation of URL and local paths cannot silently regress local uploads.Test plan
go test -race ./shortcuts/im/...golangci-lint run ./shortcuts/im/...— no new issues (two pre-existinggofmt -shints remain fromf5a8fbf; out of scope for this fix)TestMediaBufferFileName— direct struct contractTestNewMediaBufferFromBytesURLFilename— URL →mediaBuffer.namewiring across path / query / percent-encoded / fallback / non-http casesTestUploadFileToIMPreservesLocalFileName— asserts the multipartfile_namefield for local uploadsSummary by CodeRabbit
Bug Fixes
Tests