Skip to content

Block recreation flow when we try to do it on opposite direction flow - #6889

Open
dkurepa wants to merge 2 commits into
mainfrom
dkurepa/BlockOppositeDirectionRecreationFlow
Open

dkurepa wants to merge 2 commits into
mainfrom
dkurepa/BlockOppositeDirectionRecreationFlow

Conversation

@dkurepa

@dkurepa dkurepa commented Nov 16, 2026

Copy link
Copy Markdown
Member

Copilot AI balanced review requested due to automatic review settings November 16, 2026 13:46

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.

🟡 Changes recommended

A critical guard gap still allows fresh-PR replay to revert target-only fixes during unrelated patch conflicts, and existing tests bypass or inject the guard rather than verify its protection.

2 open issues
What changed in this PR

This PR addresses #6822 by blocking opposite-direction flow recreation during existing PR updates, aiming to prevent conflict recovery from overwriting target-only changes.

Changes:

  • Adds a blocking exception and recreation guard, with force/unsafe overrides.
  • Updates blocked-flow notifications to explain the risk of reverting target-branch changes.
  • Adds updater tests for blocking exceptions and adjusts notification tests.

Codeflow tests were not run in this review environment; please run dotnet test test/Darc/Microsoft.DotNet.DarcLib.Codeflow.Tests.

File Description
test/​ProductConstructionService/​ProductConstructionService.DependencyFlow.Tests/​PullRequestUpdaterTests.cs Adds a blocking-exception mock helper and updates notification matching.
test/​ProductConstructionService/​ProductConstructionService.DependencyFlow.Tests/​PullRequestCommenterTests.cs Updates duplicate-comment checks for the new notification.
test/​ProductConstructionService/​ProductConstructionService.DependencyFlow.Tests/​PendingCodeFlowUpdatesTests.cs Tests blocked PR state and outcomes for both exception types.
src/​ProductConstructionService/​ProductConstructionService.DependencyFlow/​PullRequestUpdaters/​CodeFlowPullRequestUpdater.cs Uses the generalized blocked-flow notification.
src/​ProductConstructionService/​ProductConstructionService.DependencyFlow/​PullRequestCommentBuilder.cs Explains recreation risks and expands the force-update warning.
src/​Microsoft.DotNet.Darc/​DarcLib/​VirtualMonoRepo/​VmrCodeflower.cs Guards opposite-direction recreation for existing PR branches.
src/​Microsoft.DotNet.Darc/​DarcLib/​VirtualMonoRepo/​Exceptions.cs Defines the blocking exception for opposite-direction recreation.

Review effort: Balanced

// Replaying an opposite-direction flow on top of an existing PR branch replaces the target with a snapshot
// of the source, which can overwrite changes that haven't been flown yet. We only allow it for unsafe or forced flows.
if (previousFlows.LastFlow.IsBackflow != currentIsBackflow
&& headBranchExisted

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way a PR always gets created. I wonder if we should not create it instead and see it as a failed workitem and deal with it

…ndencyFlow/PullRequestCommentBuilder.cs

Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>
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.

3 participants