Skip to content

fix(ui): Implement pre-flight upload validation to prevent server crashes#32

Open
chinmayy777 wants to merge 2 commits intoOSIPI:mainfrom
chinmayy777:fix/frontend-upload-validation
Open

fix(ui): Implement pre-flight upload validation to prevent server crashes#32
chinmayy777 wants to merge 2 commits intoOSIPI:mainfrom
chinmayy777:fix/frontend-upload-validation

Conversation

@chinmayy777
Copy link

@chinmayy777 chinmayy777 commented Mar 1, 2026

Description

Resolves #31

📦 Stacked PR Notice: > Note for Reviewers: This PR was branched off of my infrastructure fixes in PR #8 so that I could successfully build and test the Docker containers locally.

Currently, the GitHub diff shows additional files changed, but the only new changes for this specific feature are in apps/frontend/src/app/_home/uploadHandlers.ts. Once PR #8 is merged into main, GitHub will automatically update this diff to only show the relevant optimization!

While testing the UI with diverse datasets, I noticed that if a user accidentally uploads a directory lacking valid .dcm or BIDS files, the frontend still fires a heavy, empty POST request. This causes an unhandled 500 Internal Server Error on the FastAPI backend and presents the user with an unhelpful AxiosError toast.

This PR introduces strict Pre-flight Validation in uploadHandlers.ts.

  • The UI now fails fast, intercepting empty/invalid directory uploads before hitting the network.
  • Users receive immediate, context-aware Toast notifications (e.g., "No valid DICOM files found in the selected folder").
  • This saves unnecessary server bandwidth and drastically improves the UX for researchers handling messy datasets.

Checklist

  • Code follows style guidelines
  • Tests are included and passing (UI manually tested)
  • Documentation is updated
  • No breaking changes
  • Error handling is appropriate (Replaced generic Axios errors with specific pre-flight toasts)
  • Performance considerations addressed (Prevents unnecessary API calls)
  • Security implications considered

Before the fix:
Image

After the fix:
Screenshot from 2026-03-02 01-05-17

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.

bug: Missing pre-flight validation on empty/invalid DICOM directory uploads causes 500 Server Error

1 participant