Repository navigation
Continue after oversized JSON integers with --continue-on-error - #134
Open
fbirds5230 wants to merge 1 commit into
Open
fbirds5230 wants to merge 1 commit into
fbirds5230 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the JSON Pointer CLI’s oversized-integer error handling change.
No open issues 🎉
What changed in this PR
This PR lets the JSON Pointer CLI continue processing later files when an oversized JSON integer fails to parse and --continue-on-error is enabled.
Changes:
- Catch
ValueErrorfromjson.load(), covering oversized integers and existing JSON and Unicode decoding errors. - Preserve immediate failure without
--continue-on-error. - Add subprocess regression tests with the invalid file before, between, and after valid files, using a controlled integer digit limit.
| File | Description |
|---|---|
| tests.py | Adds oversized-integer tests for continuation and fail-fast behavior. |
| bin/jsonpointer | Broadens the parsing-error handler to catch ValueError. |
Review effort: Balanced
Owner
|
Thanks! Could you please fix the merge conflict? |
This branch has not been deployed
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.
--continue-on-errorstops processing when a JSON number exceeds Python's integer string conversion limit.json.load()raisesValueErrorin that case, which escapes the current decoder-error handler and prevents later files from being read.Catch
ValueErroraroundjson.load()so the CLI reports the failure for that file and continues. This also covers the existingJSONDecodeErrorandUnicodeDecodeErrorcases. Without the flag, the error is still raised.The new subprocess tests place the oversized integer before, between, and after valid files, both with and without the flag. They set the child process's digit limit to 640 to keep the input small and reproducible. Before the fix, all three continuation cases fail; the no-flag control already passes.
Validation:
python -m unittest— 104 tests pass on CPython 3.12.14 and 3.13.5.coverage run --source=jsonpointer -m unittestandcoverage report -m— pass on CPython 3.12.14.python -m flake8— pass with flake8 7.5.0.