Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix patch order for interdependent move operations#163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-160

Conversation

Copy link

CopilotAI commentedMay 27, 2025
edited
Loading

Issue

Whenjsonpatch.make_patch() creates patches with multiple interdependent move operations, the operations are sometimes ordered incorrectly, resulting in incorrect patch application. This happened because the order in which operations were generated didn't account for dependencies between operations.

The issue occurs when:

  1. One move operation moves a value from location A to location B
  2. Another move operation takes from location B (which now contains the value from A)

If these operations are executed in the wrong order, they can produce incorrect results.

Solution

The solution implements a dependency analysis for move operations to ensure proper order:

  1. Collect all operations from the linked list inDiffBuilder.execute()
  2. Identify move operations and analyze their dependencies
  3. Build a dependency graph where:
    • If operation A moves a value to a location that operation B then takes from, B depends on A
  4. Perform a topological sort to determine the correct execution order
  5. Reorder the operations accordingly before returning them

This approach ensures that interdependent move operations are consistently ordered for proper execution.

Example of the issue (now fixed):

src_obj= {'a': [{'id': [1]}, {'id': [2]}],'b': [{'id':5}]}tgt_obj= {'a': [{'id': []}, {'id': [1]}],'b': [{'id':5,'newKey':2}]}# Before: move operations could be in either order, sometimes causing errors# After: operations are always ordered correctly, ensuring successful patch applicationpatch=jsonpatch.make_patch(src_obj,tgt_obj)

Fixes#160.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

Co-authored-by: stefankoegl <184196+stefankoegl@users.noreply.github.com>
CopilotAI changed the title[WIP] Patch order sometimes wrongFix patch order for interdependent move operationsMay 27, 2025
CopilotAI requested a review fromstefankoeglMay 27, 2025 21:22
Copilot finished work on behalf ofstefankoeglMay 27, 2025 21:23
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stefankoeglstefankoeglAwaiting requested review from stefankoegl

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Patch order sometimes wrong

2 participants

@stefankoegl

[8]ページ先頭

©2009-2025 Movatter.jp