fix: encode fileId before building the upload status polling URL - #321
Conversation
pollUploadStatus interpolated the server-provided fileId directly into GET .../status/<fileId> without encoding it. file-upload-api's simple (non-chunked) upload path derives file_id from the raw original filename, so a name like "...20x10ft@50%_Ver1.4...pdf" produced a malformed URL (invalid percent-escape) - the request failed, surfaced in the browser as an opaque CORS error, and the upload got stuck in "Loading" forever. encodeURIComponent the fileId regardless of what the server sends.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesUpload status URL encoding
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change safely encodes upload status identifiers before constructing the polling URL and includes targeted passing tests; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
ref: https://app.clickup.com/t/9014802374/86bbhvqdm
Problem
pollUploadStatus(dropzone/index.js) builds the async-processing status URL as:fileIdis interpolated raw. For file-upload-api's simple (non-chunked) upload path,file_idis derived server-side from the original client filename (see companionfile-upload-apiPR). A filename likeHPE_OCPSanJose_Backdrop_20x10ft@50%_Ver1.4_PRINT.pdfproduces afile_idwith an invalid percent-escape (%_), which breaks the pollingfetch()call. The browser reports this as a CORS failure (no CORS headers on the rejected malformed request), thecatchblock swallows it viathis.onError, and the file row stays in "Loading" forever.Chunked (large) uploads never hit this — they're tracked by dropzone's own clean
dzuuid, not a filename-derived id.Fix
encodeURIComponent(fileId)before buildingstatusUrl. Defense-in-depth alongside the server-side fix (file-upload-api sanitizesfile_idat the source) - this protects against any other unsafe character reaching the client regardless of what the server sends.Testing
test_dropzone_poll_upload_status_encodes_file_id_in_url, red-green verified against the fix.npx jest src/components/inputs/dropzone src/components/inputs/upload-input-v3— 63/63 pass.Companion fixes (defense-in-depth, separate PRs):
file-upload-api: sanitize the filename used to buildfile_idat the source.sponsor-services: surface polling failures via a snackbar instead of silently swallowing them.Summary by CodeRabbit