✨(frontend) warn the user when trying to upload a file size that exceeds the limit#2522
✨(frontend) warn the user when trying to upload a file size that exceeds the limit#2522magopian wants to merge 8 commits into
Conversation
The frontend needs this value to validate the file size before upload, to display a nice error message instead of the cryptic 413 error when Nginx rejects files over 10MB. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
1d9d753 to
9b283b4
Compare
Nginx rejects files over 10MB with a 413 and an HTML body. Parsing it as JSON throws a SyntaxError, swallowing the error and showing no feedback to the user. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
9197bb9 to
0d2171c
Compare
Check the file size client-side before attempting the upload and throw a clear APIError instead. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
0d2171c to
02171c3
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughThe configuration API and frontend types now expose Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx`:
- Around line 267-286: Update the existing pasteHandler to validate clipboard
files with checkFileSize before invoking defaultPasteHandler. Return early when
validation fails so oversized pasted files cannot create stuck loading blocks,
while preserving the existing thread refresh and default paste behavior for
valid files.
In
`@src/frontend/apps/impress/src/features/docs/doc-editor/hook/useUploadFile.tsx`:
- Around line 66-68: Update the errorAttachment assignment in the upload hook to
prioritize sizeError over the existing errorAttachment, while preserving the
current isErrorAttachment and sizeErrorKey behavior. This ensures a newly
detected file-size error is returned instead of a stale React Query upload
error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0b0a87c2-f434-410c-a8a5-aeb016fa4b2c
📒 Files selected for processing (11)
CHANGELOG.mdsrc/backend/core/api/viewsets.pysrc/backend/core/tests/test_api_config.pysrc/frontend/apps/e2e/__tests__/app-impress/doc-editor-upload.spec.tssrc/frontend/apps/e2e/__tests__/app-impress/utils-common.tssrc/frontend/apps/impress/src/api/__tests__/utils.test.tssrc/frontend/apps/impress/src/api/utils.tssrc/frontend/apps/impress/src/core/config/api/useConfig.tsxsrc/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsxsrc/frontend/apps/impress/src/features/docs/doc-editor/hook/__tests__/useUploadFile.test.tsxsrc/frontend/apps/impress/src/features/docs/doc-editor/hook/useUploadFile.tsx
Set the error state if the file is too big so the UI displays a clear message, and then throw so BlockNote aborts the upload. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
Uploading a too big file displays an error message to the user, and we need to make sure that - the "loading" node isn't left over - when hiding the error message, and re-uploading the too big file, the error message displays again Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
The same way it's checking before uploading a file using the drag and drop, it also checks if it's via copy/paste. Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
6d0d6f7 to
6822be9
Compare
Fixes #2460
Purpose
Currently the message displayed to the user conveys no information on the error that occured when uploading a big file which size exceeds the limit.
Proposal
DOCUMENT_IMAGE_MAX_SIZEconfiguration through the/api/v1.0/configendpointHTTP 413messageExternal contributions
Thank you for your contribution! 🎉
Please ensure the following items are checked before submitting your pull request:
General requirements
Skip the checkbox below 👇 if you're fixing an issue or adding documentation
CI requirements
git commit --signoff(DCO compliance)git commit -S)<gitmoji>(type) title description## [Unreleased]section (if noticeable change)AI requirements
Skip the checkboxes below 👇 If you didn't use AI for your contribution