Skip to content

✨(frontend) warn the user when trying to upload a file size that exceeds the limit#2522

Open
magopian wants to merge 8 commits into
suitenumerique:mainfrom
magopian:fix/ux-feedback-on-too-big-file-upload
Open

✨(frontend) warn the user when trying to upload a file size that exceeds the limit#2522
magopian wants to merge 8 commits into
suitenumerique:mainfrom
magopian:fix/ux-feedback-on-too-big-file-upload

Conversation

@magopian

@magopian magopian commented Jul 13, 2026

Copy link
Copy Markdown

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

  • expose the DOCUMENT_IMAGE_MAX_SIZE configuration through the /api/v1.0/config endpoint
  • check the size of the file before trying to upload it
  • optional: also display a nice error message to the user if the production nginx server answers with a HTTP 413 message

External 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

  • Before submitting a PR for a new feature I made sure to contact the product manager

CI requirements

  • I made sure that all existing tests are passing
  • I have signed off my commits with git commit --signoff (DCO compliance)
  • I have signed my commits with my SSH or GPG key (git commit -S)
  • My commit messages follow the required format: <gitmoji>(type) title description
  • I have added a changelog entry under ## [Unreleased] section (if noticeable change)

AI requirements

Skip the checkboxes below 👇 If you didn't use AI for your contribution

  • I used AI assistance to produce part or all of this contribution
  • I have read, reviewed, understood and can explain the code I am submitting
  • I can jump in a call or a chat to explain my work to a maintainer

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>
@magopian
magopian force-pushed the fix/ux-feedback-on-too-big-file-upload branch from 1d9d753 to 9b283b4 Compare July 13, 2026 15:33
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>
@magopian
magopian force-pushed the fix/ux-feedback-on-too-big-file-upload branch 2 times, most recently from 9197bb9 to 0d2171c Compare July 14, 2026 08:01
Check the file size client-side before attempting the upload and throw a
clear APIError instead.

Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
@magopian
magopian force-pushed the fix/ux-feedback-on-too-big-file-upload branch from 0d2171c to 02171c3 Compare July 14, 2026 08:56
@magopian
magopian marked this pull request as ready for review July 14, 2026 11:59
@magopian magopian changed the title 🚧(frontend) warn the user when trying to upload a file size that exceeds the limit ✨(frontend) warn the user when trying to upload a file size that exceeds the limit Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d2545aa8-8052-4acf-b19c-3e149bff8b7b

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0d6f7 and 6822be9.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/frontend/apps/e2e/__tests__/app-impress/doc-editor-upload.spec.ts
  • src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts
  • src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx
  • src/frontend/apps/impress/src/features/docs/doc-editor/hook/__tests__/useUploadFile.test.tsx
  • src/frontend/apps/impress/src/features/docs/doc-editor/hook/useUploadFile.tsx

Walkthrough

The configuration API and frontend types now expose DOCUMENT_IMAGE_MAX_SIZE. useUploadFile validates files before upload, reports translated size errors, and preserves backend error behavior. The document editor blocks oversized drops and pastes and refreshes the error display for retries. API error parsing now tolerates non-JSON responses. Unit and Playwright tests cover configuration, validation, error handling, and repeated oversized uploads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: antolc

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: warning users when uploads exceed the size limit.
Description check ✅ Passed The description is directly related to the PR and matches the implemented upload-size UX improvements.
Linked Issues check ✅ Passed The changes satisfy #2460 by exposing the size config, validating file size before upload, and handling 413 errors gracefully.
Out of Scope Changes check ✅ Passed The diff stays focused on oversized upload handling, related config wiring, and tests with no unrelated scope creep.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d2dd5b and 6d0d6f7.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • src/backend/core/api/viewsets.py
  • src/backend/core/tests/test_api_config.py
  • src/frontend/apps/e2e/__tests__/app-impress/doc-editor-upload.spec.ts
  • src/frontend/apps/e2e/__tests__/app-impress/utils-common.ts
  • src/frontend/apps/impress/src/api/__tests__/utils.test.ts
  • src/frontend/apps/impress/src/api/utils.ts
  • src/frontend/apps/impress/src/core/config/api/useConfig.tsx
  • src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx
  • src/frontend/apps/impress/src/features/docs/doc-editor/hook/__tests__/useUploadFile.test.tsx
  • src/frontend/apps/impress/src/features/docs/doc-editor/hook/useUploadFile.tsx

magopian added 5 commits July 14, 2026 15:35
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>
@magopian
magopian force-pushed the fix/ux-feedback-on-too-big-file-upload branch from 6d0d6f7 to 6822be9 Compare July 14, 2026 13:36
@AntoLC
AntoLC self-requested a review July 20, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Big file upload fails as unknown error with poor UX feedback

1 participant