Skip to content

Fix JSON Patch move and copy array targets#136

Open
gaoflow wants to merge 1 commit into
jg-rp:mainfrom
gaoflow:fix-json-patch-move-copy-array-targets
Open

Fix JSON Patch move and copy array targets#136
gaoflow wants to merge 1 commit into
jg-rp:mainfrom
gaoflow:fix-json-patch-move-copy-array-targets

Conversation

@gaoflow

@gaoflow gaoflow commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • apply the existing JSON Patch add target semantics to move and copy operations
  • support the - array target for appending moved or copied values
  • reject target indexes greater than the array length instead of silently appending them

Problem

RFC 6902 defines move as a removal followed by add, and copy as add using the source value. The implementation handled their destinations separately with list.insert(), bypassing the boundary behavior fixed for add in #118. As a result, an array target ending in - leaked a native ValueError, while an index greater than the array length was silently clamped to the end by Python.

Delegating the destination step to OpAdd keeps these three standard operations on one target implementation while preserving the deep copy required by copy.

Testing

  • 2828 passed, 1 skipped
  • ruff check .
  • mypy (86 source files)

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.

1 participant