fix: guard remaining DataFileRoute endpoints against null #439
Open
parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
Open
fix: guard remaining DataFileRoute endpoints against null #439parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
Conversation
…delname Eight endpoints in DataFileRoute.py crash with UnboundLocalError when the request body contains a null casename or modelname. The if-None conditional skips the body, response is never assigned, and return jsonify(response) raises UnboundLocalError - producing a raw 500 Internal Server Error with a full stack trace. Affected routes: generateDataFile, createCaseRun, updateCaseRun, deleteScenarioCaseRuns, saveView, updateViews, batchRun, cleanUp. Fix: add an early return with 400 Bad Request before each conditional, using the same guard pattern already present in deleteCaseRun (line 77). This is a follow-up to PR EAPD-DRB#253 which fixed the same bug class in readDataFile and validateInputs but left the other eight routes unguarded. Also a sibling of issue EAPD-DRB#288 (batchRun crash).
Author
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.
Linked issue
modelnameorcasenameisNonein DataFileRoute Endpoints #252, [Bug]/batchRuncrashes withUnboundLocalErrorwhenmodelnameis null #288Existing related work reviewed
modelnameorcasenameisNonein DataFileRoute Endpoints #252 (original bug report), PR fix: validate casename to prevent UnboundLocalError crashes (fixes #252) #253 (partial fix for readDataFile/validateInputs), [Bug]/batchRuncrashes withUnboundLocalErrorwhenmodelnameis null #288 (batchRun crash, same root cause), PR Absorb MUIO v5.5 changes #422 (added the guard pattern to deleteCaseRun).Overlap assessment
Why this PR should proceed
modelnameorcasenameisNonein DataFileRoute Endpoints #252). Uses the exact guard pattern already present in deleteCaseRun (written by the maintainer in PR Absorb MUIO v5.5 changes #422). 1 file, purely additive null checks, zero behavior change for valid requests.Summary
return 400guards to 8 DataFileRoute endpoints (generateDataFile, createCaseRun, updateCaseRun, deleteScenarioCaseRuns, saveView, updateViews, batchRun, cleanUp).UnboundLocalErrorwhencasename/modelnameisnull, producing a raw 500 with a full stack trace instead of a clean 400 JSON response.Validation
python -m py_compile API/Routes/DataFile/DataFileRoute.pypasses.git diff --checkclean. Branched off latestupstream/main(5f8f89a).Documentation
Scope check
fix/unbound-local-datafile-routes)OSeMOSYS/MUIOdependencyEAPD-DRB/MUIOGO:mainException rationale
N/A