Skip to content

Normalize oversized array index conversion errors - #83

Merged
stefankoegl merged 1 commit into
stefankoegl:masterfrom
fhgffy:fix/oversized-array-index
Oct 2, 2026
Merged

stefankoegl merged 1 commit into
stefankoegl:masterfrom
fhgffy:fix/oversized-array-index

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

A long numeric array token passes the index syntax check but can exceed Python's integer-string conversion limit. The resulting ValueError escapes resolve()'s JsonPointerException handler, so a supplied default is ignored.

With the default 4300-digit limit, resolve_pointer([0], '/' + '1' * 4301, default=None) currently raises ValueError. This patch returns None; without a default it raises JsonPointerException.

The change catches ValueError only around int(part), preserving Python's safety limit. Five regression tests cover resolution, nested defaults, to_last, both inplace modes, and long numeric mapping keys, which remain valid.

Validation:

  • On the unmodified base, four new test methods fail (five errors across the inplace cases); the mapping-key control passes
  • Full unittest/doctest suite: 36 passed on Python 3.12.14 and 3.13.5
  • flake8 passes; configured coverage run passes with 98% aggregate coverage
  • Clean patch application and all 36 tests verified against 8c0bfdd
  • Python 3.10, 3.11 and 3.14 runtimes were not run locally. The new tests skip if the integer-limit API is missing or its limit is disabled

@stefankoegl
stefankoegl requested a balanced review from Copilot October 2, 2026 12:34
@fhgffy
fhgffy marked this pull request as ready for review October 2, 2026 12:34

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.

Copilot review overview

🟢 Approval recommended

The focused exception handling preserves valid mapping keys and is comprehensively tested across affected APIs.

Review effort: Balanced
Findings: None

What changed in this PR

Normalizes oversized array-index conversion failures into JsonPointerException, allowing defaults to work consistently.

Changes:

  • Wraps sequence index conversion errors.
  • Adds regression coverage for resolution, assignment, nested defaults, and mapping keys.
File Description
jsonpointer.py Converts oversized index ValueError into JsonPointerException.
tests.py Adds oversized numeric-token regression tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@stefankoegl
stefankoegl merged commit c625f3b into stefankoegl:master Oct 2, 2026
6 checks passed
@stefankoegl

Copy link
Copy Markdown
Owner

Thanks!

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.

3 participants