fix(upload): correct on_drop_rejected args spec#6342
fix(upload): correct on_drop_rejected args spec#6342BABTUNA wants to merge 1 commit intoreflex-dev:mainfrom
Conversation
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe 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 No files require special attention. Important Files Changed
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]
Reviews (1): Last reviewed commit: "Fix upload on_drop_rejected args spec" | Re-trigger Greptile |
| 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]] |
There was a problem hiding this comment.
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.
All Submissions:
github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md) file?
Requests for the desired
changed?
Type of change
New Feature Submission:
Changes To Core Features:
like us to include them?
Description
This fixes the
Upload.on_drop_rejectedtrigger args spec.Before this change,
on_drop_rejectedused the same spec ason_drop(
list[rx.UploadFile]), which is incorrect for rejected files.Now
on_drop_rejecteduses its own spec (list[dict[str, Any]]) and iswired on both
GhostUploadandUpload.Changes included:
_on_drop_rejected_spec = passthrough_event_spec(list[dict[str, Any]]).on_drop_rejectedtype annotations inGhostUploadandUpload.test_on_drop_rejected_uses_file_rejection_payload_specpyi_hashes.jsonforpackages/reflex-components-core/src/ reflex_components_core/core/upload.pyi.Validation
uv run pytest tests/units/components/core/test_upload.py -quv run ruff check packages/reflex-components-core/src/ reflex_components_core/core/upload.py tests/units/components/core/ test_upload.pyCloses #6205