Skip to content

Raise JsonPatchConflict when removing from immutable containers - #245

Merged
stefankoegl merged 1 commit into
stefankoegl:masterfrom
boogu2005:codex/immutable-remove-conflict
Nov 1, 2026
Merged

stefankoegl merged 1 commit into
stefankoegl:masterfrom
boogu2005:codex/immutable-remove-conflict

Conversation

@boogu2005

Copy link
Copy Markdown
Contributor

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:

  • tests.py: 234 tests, including 1 platform-specific skip.
  • property_tests.py: 21 tests.
  • Standalone doctests: 33 examples.
  • Fatal Flake8 checks on all tracked Python sources pass.
  • Distribution builds, strict Twine checks, and the Sphinx warnings-as-errors build pass.

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 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 TypeError to JsonPatchConflict.
  • 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

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — boogu2005:codex/immutable-remove-conflict into stefankoegl:master

@stefankoegl
stefankoegl merged commit 20add79 into stefankoegl:master Nov 1, 2026
20 of 21 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