fix: add missing request field validation to all ViewDataRoute endpoints#448
Open
parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
Open
fix: add missing request field validation to all ViewDataRoute endpoints#448parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
parthdagia05 wants to merge 1 commit intoEAPD-DRB:mainfrom
Conversation
All four ViewDataRoute.py endpoints access request.json fields directly without validate_json_fields, unlike every other route file in the API. A request with any missing field crashes with KeyError and returns a raw 500 stack trace to the client. This was the same bug class fixed by PR EAPD-DRB#79 across 10 other routes and tracked in issues EAPD-DRB#77 and EAPD-DRB#185, but ViewDataRoute was missed when those fixes landed. Adds validate_json_fields calls to: - viewData (1 field: casename) - viewTEData (1 field: casename) - updateViewData (10 fields: casename, year, ScId, groupId, paramId, TechId, CommId, EmisId, Timeslice, value) - updateTEViewData (7 fields: casename, scId, groupId, paramId, techId, emisId, value)
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
Existing related work reviewed
Overlap assessment
Why this PR should proceed
validate_json_fieldsutility identically to every other route file. 1 file, 13 lines added, zero behavior change for valid requests.updateViewDataandupdateTEViewDataare core data editing routes every cell edit in the parameter grid hits them.Summary
validate_json_fields()calls to all 4 ViewDataRoute.py endpoints (viewData, viewTEData, updateViewData, updateTEViewData).KeyError→ raw 500 stack trace. Every other route file already validates; ViewDataRoute was skipped.Validation
validate_json_fieldsutility which is already tested.python -m py_compile API/Routes/Case/ViewDataRoute.pypasses.git diff --checkclean. Branched off latestupstream/main(5f8f89a).Documentation
Scope check
fix/viewdataroute-missing-input-validation)OSeMOSYS/MUIOdependencyEAPD-DRB/MUIOGO:mainException rationale
N/A