Skip to content

fix: return clear invalid modality and dsc placeholder responses#61

Open
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-35
Open

fix: return clear invalid modality and dsc placeholder responses#61
AlwinXue wants to merge 1 commit intoOSIPI:mainfrom
AlwinXue:alwin/fix-issue-35

Conversation

@AlwinXue
Copy link
Copy Markdown

@AlwinXue AlwinXue commented Mar 31, 2026

Hi mentors! 👋

This PR addresses the invalid modality handling and DSC placeholder behavior reported in Issue #35.

The Problem:
Invalid modality values were bubbling into the backend flow as uncaught exceptions, which produced 500 responses instead of clear client errors. Separately, DSCProcessor.process() returned a bare string ("dsc data"), which is not a stable API shape for callers expecting structured report data.

The Solution:
Clear Modality Parsing: Added a small modality parsing helper in the backend router so unsupported values now return 400 Bad Request with a deterministic Unsupported modality: ... message.
Structured DSC Placeholder: Updated DSCProcessor to return a dictionary placeholder with modality, status, and message fields instead of a raw string.
Regression Coverage: Added a backend test for invalid modality handling and a package test that locks in the DSC placeholder response format.

Validation:
Ran python -m pytest apps/backend/tests/test_report.py -q -k "test_get_report_bids_invalid_modality" (with DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib) and python -m pytest package/src/pyaslreport/tests/test_dsc_processor.py -q; both targeted tests passed.

Fixes #35

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.

Invalid modality input causes 500 and DSCProcessor returns hardcoded string

1 participant