Skip to content

Reject moving any location into its own children, fixes #214 - #222

Merged
stefankoegl merged 1 commit into
masterfrom
claude/sharp-cori-zfkr2e
Oct 9, 2026
Merged

stefankoegl merged 1 commit into
masterfrom
claude/sharp-cori-zfkr2e

Conversation

@stefankoegl

Copy link
Copy Markdown
Owner

RFC 6902, 4.4 forbids "from" being a proper prefix of "path". This was
only enforced when the moved value was an object member: an array
element was removed first and the target then resolved against the
shifted array, so [[], []] with a move from /0 to /0/0 silently moved
the first element into the second. Moving the whole document ("from"
is "") crashed with a TypeError for arrays, because the value was
looked up with a None index before any check.

The prefix check now runs before anything is resolved, for all
container types. Moving a location onto itself stays a no-op,
including "" onto "".

This reverts the behaviour added in 7e459af, which allowed moving an
array item into a sibling; test_move_array_item_into_other_item now
expects a conflict.

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

RFC 6902, 4.4 forbids "from" being a proper prefix of "path". This was
only enforced when the moved value was an object member: an array
element was removed first and the target then resolved against the
shifted array, so [[], []] with a move from /0 to /0/0 silently moved
the first element into the second. Moving the whole document ("from"
is "") crashed with a TypeError for arrays, because the value was
looked up with a None index before any check.

The prefix check now runs before anything is resolved, for all
container types. Moving a location onto itself stays a no-op,
including "" onto "".

This reverts the behaviour added in 7e459af, which allowed moving an
array item into a sibling; test_move_array_item_into_other_item now
expects a conflict.

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

2 participants