Skip to content

fix: TextCanvas.apply_patch validates context lines - #8203

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/8193-textcanvas-stale-patch
Open

fix: TextCanvas.apply_patch validates context lines#8203
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/8193-textcanvas-stale-patch

Conversation

@wasim-builds

Copy link
Copy Markdown

Fixes #8193

This PR modifies TextCanvas.apply_patch to construct the expected source lines from the hunk and validate that the lines in the current working copy exactly match the source context before allowing the patch to apply.
If the context does not match, a ValueError is raised, preventing stale patches from silently applying over newer edits.

A regression test is included to ensure patch application rejects hunks if their source context doesn't match.

Copilot AI lite review requested due to automatic review settings September 7, 2026 07:56

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

TextCanvas.apply_patch accepts stale hunks without validating context lines

2 participants