Skip to content

[fix] Missing session validation in file download routes causes 500 Internal Error#239

Closed
krrishrastogi05 wants to merge 1 commit intoEAPD-DRB:mainfrom
krrishrastogi05:Unsafe-session-retrieval-in-file-download-routes
Closed

[fix] Missing session validation in file download routes causes 500 Internal Error#239
krrishrastogi05 wants to merge 1 commit intoEAPD-DRB:mainfrom
krrishrastogi05:Unsafe-session-retrieval-in-file-download-routes

Conversation

@krrishrastogi05
Copy link
Copy Markdown
Contributor

@krrishrastogi05 krrishrastogi05 commented Mar 5, 2026

Summary

  • What changed: Inserted minimal validation checks into /downloadFile, /downloadCSVFile, and /downloadResultsFile in DataFileRoute.py. Added explicit catch blocks for TypeError. (Note: downloadDataFile was left untouched to preserve existing commented code/structure).
  • Why: To prevent unhandled TypeError exceptions from crashing the server. Previously, if session.get('osycase') was None, passing it to pathlib.Path bypassed the IOError catch block, resulting in a 500 Internal Server Error.

Related issues

Validation

  • Tests added/updated (or not applicable)
  • Validation steps documented
    • Steps Taken:
      1. Sent a GET request to /downloadFile without an active session -> Verified it returns a safe 400 error.
      2. Sent GET requests missing URL parameters -> Verified they return 400 errors.

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)

@SeaCelo SeaCelo added bug Something isn't working Priority: Low labels Mar 6, 2026
@SeaCelo
Copy link
Copy Markdown
Collaborator

SeaCelo commented Apr 9, 2026

@krrishrastogi05 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

bug Something isn't working Priority: Low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Missing session validation in file download routes causes 500 Internal Server Error

2 participants