fix: enforce _MAX_DATA_BYTES limit on learning-path payloads#1208
Open
mrudulaa11 wants to merge 1 commit into
Open
fix: enforce _MAX_DATA_BYTES limit on learning-path payloads#1208mrudulaa11 wants to merge 1 commit into
mrudulaa11 wants to merge 1 commit into
Conversation
The 64KB size guard defined in main_routes.py was never actually referenced by create_path() or update_path(), leaving learning-path requests with no enforced size limit. - Add _payload_too_large() helper that checks the raw request body against _MAX_DATA_BYTES before JSON parsing - Call it in both create_path() (POST) and update_path() (PUT) - Return 400 with a descriptive error when the limit is exceeded - Add tests covering oversized POST/PUT payloads and confirm within-limit requests are unaffected Fixes komalharshita#1137
|
@mrudulaa11 is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary [required]
_MAX_DATA_BYTESwas defined insrc/routes/main_routes.pywith a commentstating it guards against oversized payloads, but it was never actually
checked anywhere. This PR wires it up.
Related Issue [required]
Closes #1137
Type of Change [required]
data/projects.jsonWhat Was Changed [required]
src/routes/main_routes.py_payload_too_large()helper; called it increate_path()andupdate_path()before JSON parsing, returning400when the raw body exceeds_MAX_DATA_BYTES(64KB)tests/test_basic.pyHow to Test This PR [required]
git checkout fix/learning-path-payload-size-limitpip install -r requirements.txtpython app.py/api/learning-path/test123with headerX-Learning-Path-Token: anytokenand a JSON body over 64KB — confirm you get a400with a size-limit error instead of201python -m pytest tests/test_basic.py -vSelf-Review Checklist [required]
fix/learning-path-payload-size-limitpython -m pytest tests/test_basic.pyand all tests passflake8 .locally and there are no errorsprint()orconsole.log()debug statementsNotes for Reviewer
None.