Skip to content

fix(#356): add session null-check to download endpoints#364

Closed
Anirudh77715 wants to merge 1 commit intoEAPD-DRB:mainfrom
Anirudh77715:feature/356-fix-download-session-null-check
Closed

fix(#356): add session null-check to download endpoints#364
Anirudh77715 wants to merge 1 commit intoEAPD-DRB:mainfrom
Anirudh77715:feature/356-fix-download-session-null-check

Conversation

@Anirudh77715
Copy link
Copy Markdown

@Anirudh77715 Anirudh77715 commented Mar 23, 2026

Download endpoints crashed with TypeError when no case session was set because None was passed to Path().

Linked issue

Existing related work reviewed

Overlap assessment

Why this PR should proceed

session.get('osycase', None) returns NonePath(None) raises TypeError → uncaught → HTML 500 for all download endpoints. This PR adds a session null-check guard returning a 400 JSON error instead.

Summary

  • What changed: Added session null-check guard to 5 download endpoints in DataFileRoute.py and CaseRoute.py
  • Why: Path(None) raises TypeError causing uncaught 500 errors on all download routes when no case session exists

Validation

  • Tests added/updated (or not applicable)
  • Validation steps documented
  • Evidence attached (logs/screenshots/output as relevant)

Documentation

  • Docs updated in this PR (or not applicable)
  • Any setup/workflow changes reflected in repo docs

Scope check

  • No unrelated refactors
  • Implemented from a feature branch
  • Change is deliverable without upstream OSeMOSYS/MUIO dependency
  • Base repo/branch is EAPD-DRB/MUIOGO:main (not upstream)

Exception rationale

Download endpoints (downloadDataFile, downloadFile, downloadCSVFile,
downloadResultsFile, downloadCSV) crashed with TypeError when no case
session was set because None was passed to Path(). Now each endpoint
validates the session and returns a 400 JSON error if no case is active.
@github-actions github-actions bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Mar 23, 2026
@github-actions github-actions bot removed the needs-intake-fix PR intake structure needs maintainer follow-up label Apr 2, 2026
@SeaCelo
Copy link
Copy Markdown
Collaborator

SeaCelo commented Apr 9, 2026

@Anirudh77715 Thanks for the work here. I’m closing this in favor of #416, which we’re keeping as the current implementation PR for the missing-session download crash tracked under #240.

@SeaCelo SeaCelo closed this Apr 9, 2026
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] Download endpoints crash with TypeError when no case session is set - None passed to Path()

2 participants