fix(frontend): don't count dropped folders as failures - #7841
Open
Raja-Hamid wants to merge 1 commit into
Open
Conversation
Dropping a folder onto the dataset file uploader reported "1 file failed to be selected." even though nothing failed and nothing was meant to be uploaded. fileDropped settles one promise per dropped entry, and there are three outcomes: a valid file resolves to an item, a directory deliberately resolves to null, and an oversized or unreadable file rejects. The failure count was derived from the difference between the total settled results and the non-null successes, so a directory -- fulfilled, but filtered out as null -- was indistinguishable from a genuine rejection. Count the rejected results directly instead. Directories are ignored silently, while files that really did fail are still reported, with the existing singular/plural wording. Closes apache#7457
Contributor
Backport auto-label reportThis
|
Contributor
Automated Reviewer SuggestionsBased on the
|
Contributor
Author
|
@aglinxinyuan , Kindly review this. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7841 +/- ##
============================================
+ Coverage 91.58% 91.59% +0.01%
Complexity 4501 4501
============================================
Files 1173 1173
Lines 47352 47350 -2
Branches 5307 5306 -1
============================================
+ Hits 43366 43369 +3
+ Misses 2342 2336 -6
- Partials 1644 1645 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dropping a folder onto the dataset file uploader reported "1 file failed to be selected." even though nothing failed and nothing was meant to be uploaded.
fileDropped settles one promise per dropped entry, and there are three outcomes: a valid file resolves to an item, a directory deliberately resolves to null, and an oversized or unreadable file rejects. The failure count was derived from the difference between the total settled results and the non-null successes, so a directory -- fulfilled, but filtered out as null -- was indistinguishable from a genuine rejection.
Count the rejected results directly instead. Directories are ignored silently, while files that really did fail are still reported, with the existing singular/plural wording.
Closes #7457
What changes were proposed in this PR?
Dropping a folder onto the dataset file uploader showed a red banner reading "1 file failed to be selected." — even though nothing failed and nothing was meant to be uploaded. Valid files dropped alongside it were still selected correctly; only the banner was wrong.
fileDroppedsettles one promise per dropped entry (files-uploader.component.ts:283-312), with three possible outcomes:successfulUploads?results?resolve({...})resolve(null)(:310)nullreject(...)(:295,:306)successfulUploadskeeps only fulfilled non-null values (:319-322), but the failure count was derived from the raw length:That difference equals rejections + directories. A directory is fulfilled-with-
null, never a rejection, so it was indistinguishable from a genuine failure and inflated the count.The fix counts rejections directly, as the issue proposes:
resolve(null)occurs only in the non-file branch, so fulfilled-nullcorresponds exactly to a directory, and bothrejectsites are real failures. Directories are now ignored silently; files that genuinely failed are still reported, with the singular/plural wording untouched.The behaviour change is limited to that banner — selection, conflict resolution, and emission are unaffected.
Any related issues, documentation, discussions?
Closes #7457
How was this PR tested?
Added five tests under
describe("dropped folders are not failures")infiles-uploader.component.spec.ts, plus adroppedDirectory()helper building an entry withisFile: false(the existingdroppedFile()helper always setsisFile: true):fileUploadingFinished === falseand an empty message1 file failed to be selected.— green before and after, guarding the real-failure path2 files failed to be selected.Command:
3 files failed to be selected.where2 files failed to be selected.was expected — the dropped folder inflating the count.Regression sweep including
dataset-detail.component.spec.ts, the only component embedding the uploader:Result: 2 files, 230/230 passing.
yarn prettier-eslintreports both touched files unchanged.Before / after: dropping a folder previously raised a red "1 file failed to be selected." banner; it now completes silently.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Yes, Alongside Claude Code