Skip to content

fix: upload input v4, identify File on error and on dismiss - #399

Open
tomrndom wants to merge 1 commit into
v5.xfrom
fix/upload-input-v4-error-file
Open

tomrndom wants to merge 1 commit into
v5.xfrom
fix/upload-input-v4-error-file

Conversation

@tomrndom

@tomrndom tomrndom commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

ref: https://app.clickup.com/t/9014802374/86bd1y0qx

this is based on the comments from fntechgit/call-for-presentations#106 (comment)

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features
    • Upload error callbacks now include the failed file, including when other files are still uploading.
    • Dismissing an upload-error row removes the failed file from the upload list and calls the removal callback when the file was in the upload queue. Dismissing a file rejected before upload does not call the removal callback.
  • Documentation
    • Clarified upload callback behavior and what happens when an error row is dismissed.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

UploadInputV4 now passes the failed File to onError. Dismissing an upload-error row calls onRemove when the file remains in Uppy. Tests cover failures with multiple files and dismissal of files rejected before upload.

Changes: Upload error handling

Layer / File(s) Summary
Pass the failed file to onError
src/components/inputs/upload-input-v4/index.js, src/components/inputs/upload-input-v4/__tests__/upload-input-v4.test.js
onError receives the failed File as its fourth argument. Tests cover API rejection and a network failure while another file uploads.
Handle error-row dismissal
src/components/inputs/upload-input-v4/index.js, src/components/inputs/upload-input-v4/__tests__/upload-input-v4.test.js
Dismissing an error row removes it from the display. If its file remains in Uppy, the component removes it and calls onRemove. Tests confirm that a file rejected before upload does not trigger onRemove. The component documentation describes the callback behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to c5a8d

This change passes the failed File to onError and calls onRemove when an upload-error row is dismissed and its file is still in Uppy. The added argument leaves existing callbacks working, and the new tests cover the main paths. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: upload input v4 now identifies the File on error and on dismiss. The raw summary says onError now receives the failed File as a fourth argument, and dismissing an error row…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: upload input v4 now identifies the File on error and on dismiss. The raw summary says onError now receives the failed File as a fourth argument, and dismissing an error row calls onRemove with that File when it is still in Uppy. The title matches the main change. The conventional 'fix:' prefix is acceptable for this kind of bug fix.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e0cb21e9-d72b-4470-b85f-a3099142a4b6
Commits

Reviewing files that changed from the base of the PR and between d228413 and c5a8d5f.

Files selected for processing: 2

  • src/components/inputs/upload-input-v4/__tests__/upload-input-v4.test.js
  • src/components/inputs/upload-input-v4/index.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The lifecycle documentation incorrectly promises mutually exclusive terminal callbacks and misstates the onUploadComplete arguments, which could cause parents to process an upload attempt’s termination twice.

1 open issue
What changed in this PR

This PR lets parents identify which file failed or was dismissed in UploadInputV4, improving per-file upload tracking.

Changes:

  • Pass the original File as the fourth argument to onError.
  • Call onRemove(file) when dismissing an upload error, excluding files rejected before upload.
  • Add regression tests for file identity and dismissal callbacks, and document callback behavior.
File Description
src/​components/​inputs/​upload-input-v4/​index.js Adds file-aware error and dismissal callbacks and lifecycle documentation.
src/​components/​inputs/​upload-input-v4/​__tests__/​upload-input-v4.test.js Tests failed-file identity and dismissal behavior for uploaded and rejected files.

Review effort: Balanced

Comment on lines +91 to +94
* Every File reported through `onUploadStart` is later reported once through
* `onUploadComplete`, `onError(err, status, id, file)` or `onRemove(file)`, and a
* retry starts it again. Dismissing its error row calls `onRemove`, so a parent can
* track exactly which files are running or failed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tomrndom Agreed, and the fix should go one step further: onUploadComplete still does not say which File finished, so a parent cannot track exactly which files are running, which is what this doc block promises.

Completion is reported as (body, id, data), so the CFP form has to match the finished upload by original_name and size (isSameFile in call-for-presentations #106). Uppy builds the file id with lastModified (generateFileID in @uppy/utils), so two different files with the same name and size can upload in the same input, and the form can then drop the wrong running entry: the same stale-entry case this PR is meant to close. And as noted above, a failed file is reported twice (onError, then onRemove when its row is dismissed), so "reported once" does not hold either.

Suggested fix: pass the File on completion too. It only adds an argument, so Contract A (onUploadComplete(response, id, data) in sds/direct-to-storage-uploads-uppy-s3-multipart.md) stays intact:

// handleDelivered
if (callback) callback(body, inputId, { media_type: type, media_upload: current }, file.data);

and describe what actually happens:

 * Each attempt of a File reported through `onUploadStart` ends in
 * `onUploadComplete(body, id, data, file)` or `onError(err, status, id, file)`, unless
 * its row is deleted first, which reports `onRemove(file)`. Deleting a delivered row or
 * dismissing an error row also reports `onRemove(file)`, and a retry reports
 * `onUploadStart` again.

A test that runs retry, fail again and dismiss, and checks the callback sequence, would pin this contract down.

@santipalenque santipalenque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hey @tomrndom this looks good, but do we need a similar PR against main for uicore v6 ? cc @smarcet

@tomrndom

Copy link
Copy Markdown
Contributor Author

hey @tomrndom this looks good, but do we need a similar PR against main for uicore v6 ? cc @smarcet

Sure, I'll create the same PR pointing to v6 to keep them on sync. Thanks

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.

4 participants