Skip to content

Continue after oversized JSON integers with --continue-on-error - #134

Open
fbirds5230 wants to merge 1 commit into
stefankoegl:masterfrom
fbirds5230:fix/continue-after-json-integer-limit
Open

fbirds5230 wants to merge 1 commit into
stefankoegl:masterfrom
fbirds5230:fix/continue-after-json-integer-limit

Conversation

@fbirds5230

Copy link
Copy Markdown

--continue-on-error stops processing when a JSON number exceeds Python's integer string conversion limit. json.load() raises ValueError in that case, which escapes the current decoder-error handler and prevents later files from being read.

Catch ValueError around json.load() so the CLI reports the failure for that file and continues. This also covers the existing JSONDecodeError and UnicodeDecodeError cases. 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 unittest and coverage report -m — pass on CPython 3.12.14.
  • python -m flake8 — pass with flake8 7.5.0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 ValueError from json.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

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 98.864%. remained the same — fbirds5230:fix/continue-after-json-integer-limit into stefankoegl:master

@stefankoegl

Copy link
Copy Markdown
Owner

Thanks! Could you please fix the merge conflict?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants