Skip to content

fix(upload): correct on_drop_rejected args spec#6342

Open
BABTUNA wants to merge 1 commit intoreflex-dev:mainfrom
BABTUNA:fix-6205-on-drop-rejected-args-spec
Open

fix(upload): correct on_drop_rejected args spec#6342
BABTUNA wants to merge 1 commit intoreflex-dev:mainfrom
BABTUNA:fix-6205-on-drop-rejected-args-spec

Conversation

@BABTUNA
Copy link
Copy Markdown

@BABTUNA BABTUNA commented Apr 19, 2026

All Submissions:

  • Have you followed the guidelines stated in [CONTRIBUTING.md](https://
    github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) file?
  • Have you checked to ensure there aren't any other open Pull
    Requests
    for the desired
    changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd
    like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

This fixes the Upload.on_drop_rejected trigger args spec.

Before this change, on_drop_rejected used the same spec as on_drop
(list[rx.UploadFile]), which is incorrect for rejected files.
Now on_drop_rejected uses its own spec (list[dict[str, Any]]) and is
wired on both GhostUpload and Upload.

Changes included:

  • Added _on_drop_rejected_spec = passthrough_event_spec(list[dict[str, Any]]).
  • Updated on_drop_rejected type annotations in GhostUpload and
    Upload.
  • Added regression test:
    • test_on_drop_rejected_uses_file_rejection_payload_spec
  • Updated pyi_hashes.json for packages/reflex-components-core/src/ reflex_components_core/core/upload.pyi.

Validation

  • uv run pytest tests/units/components/core/test_upload.py -q
  • uv run ruff check packages/reflex-components-core/src/ reflex_components_core/core/upload.py tests/units/components/core/ test_upload.py

Closes #6205

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 19, 2026

Greptile Summary

This PR fixes a bug where on_drop_rejected on both GhostUpload and Upload was incorrectly typed with _on_drop_spec (list[UploadFile]) instead of the correct list[dict[str, Any]] that react-dropzone's FileRejection[] payload actually delivers. The fix introduces a dedicated _on_drop_rejected_spec constant and wires it consistently in both components, aligning with the shape already expected by the existing _default_drop_rejected helper.

Confidence Score: 5/5

Safe to merge — targeted one-line spec fix with a regression test and updated pyi hash.

All findings are P2 (minor test coverage gap). The fix is correct, well-scoped, and consistent with the existing _default_drop_rejected implementation that already used list[dict[str, Any]].

No files require special attention.

Important Files Changed

Filename Overview
packages/reflex-components-core/src/reflex_components_core/core/upload.py Introduces _on_drop_rejected_spec using list[dict[str, Any]] and wires it to GhostUpload.on_drop_rejected and Upload.on_drop_rejected, correctly replacing the previously incorrect _on_drop_spec (list[UploadFile]). The new spec aligns with the react-dropzone FileRejection[] payload shape already expected by _default_drop_rejected.
tests/units/components/core/test_upload.py Adds regression test test_on_drop_rejected_uses_file_rejection_payload_spec that verifies Upload.on_drop_rejected now carries the correct list[dict[str, Any]] placeholder type. GhostUpload is not tested separately (minor gap).
pyi_hashes.json Hash for upload.pyi updated to reflect the changed event handler type signature — consistent with the source change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[react-dropzone onDropRejected callback] -->|FileRejection array| B[on_drop_rejected trigger]
    B --> C{Component}
    C -->|GhostUpload| D["_on_drop_rejected_spec: list of dict"]
    C -->|Upload| D
    D --> E[User event handler receives list of FileRejection dicts]
Loading

Reviews (1): Last reviewed commit: "Fix upload on_drop_rejected args spec" | Re-trigger Greptile

Comment on lines +79 to +83
def test_on_drop_rejected_uses_file_rejection_payload_spec():
rejected_spec = Upload.get_event_triggers()["on_drop_rejected"]
placeholders, _ = parse_args_spec(rejected_spec)

assert placeholders[0]._var_type == list[dict[str, Any]]
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.

P2 Test only covers Upload, not GhostUpload

The new test validates the spec for Upload.on_drop_rejected, but GhostUpload.on_drop_rejected was also changed in this PR. Since both are wired to the same _on_drop_rejected_spec constant, the fix is correct for both, but the test coverage doesn't verify GhostUpload's trigger independently. Consider adding a parallel assertion for GhostUpload.get_event_triggers()["on_drop_rejected"] to ensure it stays in sync if the specs ever diverge.

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.

Upload on_drop_rejected args spec is incorrect

1 participant