Skip to content

Wrap sequence append type errors in JsonPointerException - #109

Merged
stefankoegl merged 1 commit into
stefankoegl:masterfrom
arin30:fix/sequence-append-type-error
Nov 5, 2026
Merged

stefankoegl merged 1 commit into
stefankoegl:masterfrom
arin30:fix/sequence-append-type-error

Conversation

@arin30

@arin30 arin30 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Assigning an invalid value to a bytearray element raises JsonPointerException, but appending that same value leaks TypeError:

set_pointer(bytearray([1]), '/0', 'invalid')  # JsonPointerException
set_pointer(bytearray([1]), '/-', 'invalid')  # TypeError

Catch append's TypeError alongside the existing immutable-sequence error, using the same Invalid assignment target message as indexed assignment. This also covers appends through create=True, including attempts to attach a newly built intermediate dictionary to a typed sequence.

Three regression tests cover invalid values, invalid intermediate children, valid appends, and inplace=False. Eight append subcases fail on unchanged master; the existing-index and valid-append controls pass.

Validation on Python 3.12.14: all 88 tests pass, Flake8 passes, and git diff --check is clean. No API or type stub changes.

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 were identified for the change aligning sequence append errors with indexed assignment.

No open issues 🎉

What changed in this PR

This PR makes sequence append errors consistent with indexed assignment by wrapping append TypeError exceptions in JsonPointerException.

Changes:

  • Preserve the existing “Invalid assignment target” message for invalid appends.
  • Add regression coverage for invalid values and intermediate children with create=True, valid appends, and inplace=False behavior.
File Description
tests.py Adds typed-sequence append tests covering failures, successful appends, and mutation behavior.
jsonpointer.py Catches append TypeError alongside AttributeError and updates the explanatory comment.

Review effort: Balanced

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 98.857% (+1.1%) from 97.714% — arin30:fix/sequence-append-type-error into stefankoegl:master

@stefankoegl
stefankoegl merged commit 42d6b2d into stefankoegl:master Nov 5, 2026
24 checks passed
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