Repository navigation
Raise JsonPatchConflict when removing from immutable containers - #245
Merged
stefankoegl merged 1 commit intoNov 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to report immutable-container removal failures as JsonPatchConflict.
No open issues 🎉
What changed in this PR
This PR completes immutable-container removal error handling by reporting JsonPatchConflict instead of leaking TypeError, consistent with add and replace operations.
Changes:
- Preserve the original deletion error message when converting
TypeErrortoJsonPatchConflict. - Add regression tests for tuple removal, read-only mappings, and moves from tuples without modifying the source.
- Verify that duck-typed mapping removal remains supported.
| File | Description |
|---|---|
tests.py |
Adds immutable-container regression tests and duck-typed mapping compatibility coverage. |
jsonpatch.py |
Converts deletion TypeError into JsonPatchConflict, preserving its message. |
Review effort: Balanced
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.
Removing an existing tuple item currently leaks TypeError, while add and replace reject immutable sequence targets with JsonPatchConflict.
Convert TypeError raised by item deletion into JsonPatchConflict, retaining its diagnostic message. Existing missing-key/index errors, array-index validation, and duck-typed mapping removal remain unchanged.
Regression tests cover root and nested tuples with both in_place settings, read-only mappings with in_place=True, and moving a value out of a tuple without changing the source document.
Related #188, which previously addressed related operation error handling. This change focuses on the remaining immutable-container deletion case.
Validation on Windows / Python 3.12 with published jsonpointer 3.6: