Skip to content

Raise documented exceptions for malformed patches and "from": "/-" - #224

Merged
stefankoegl merged 2 commits into
masterfrom
claude/fervent-bohr-0t4c7h
Oct 10, 2026
Merged

stefankoegl merged 2 commits into
masterfrom
claude/fervent-bohr-0t4c7h

Conversation

@stefankoegl

Copy link
Copy Markdown
Owner

Some invalid input raised a bare TypeError instead of an exception
callers catching JsonPatchException and JsonPointerException expect:

  • Patch elements that are not objects now raise InvalidJsonPatch.
  • A 'from' that is not a string or pointer raises InvalidJsonPatch,
    as a 'path' of that kind already did. 'copy' now also accepts a
    pointer object in 'from', like 'move' already did.
  • 'move' and 'copy' from the '-' of an array raise
    JsonPointerException, as 'remove' of it already did.

test_malformed_patch_raises_documented_exceptions now passes, so its
expectedFailure marker goes. test_raises_only_documented_exceptions
keeps its marker until #213 and #214 are fixed, but loses its
'copy' from '/-' example.

Fixes #215

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_012GyRw6J1pYgw9XTeNaGPwX

claude added 2 commits October 9, 2026 22:19
Some invalid input raised a bare TypeError instead of an exception
callers catching JsonPatchException and JsonPointerException expect:

- Patch elements that are not objects now raise InvalidJsonPatch.
- A 'from' that is not a string or pointer raises InvalidJsonPatch,
  as a 'path' of that kind already did. 'copy' now also accepts a
  pointer object in 'from', like 'move' already did.
- 'move' and 'copy' from the '-' of an array raise
  JsonPointerException, as 'remove' of it already did.

test_malformed_patch_raises_documented_exceptions now passes, so its
expectedFailure marker goes. test_raises_only_documented_exceptions
keeps its marker until #213 and #214 are fixed, but loses its
'copy' from '/-' example.

Fixes #215

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GyRw6J1pYgw9XTeNaGPwX
@stefankoegl
stefankoegl merged commit bb76fda into master Oct 10, 2026
5 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.

Malformed patches and "from": "/-" raise TypeError instead of InvalidJsonPatch / JsonPointerException

2 participants