Title: Does Azure DevOps reset PR auto-complete when an automatic completion attempt fails due to required build validation policies? Can this happen due to a race condition?

Yeshwanth C 0 Reputation points
2026-11-25T09:57:32.8533333+00:00

I'm trying to understand the behavior of Azure DevOps Pull Request auto-complete.

We encountered the following message in a PR:

Attempt to automatically complete failed: X pipeline must succeed to update master. Auto-complete has been reset.

From what I understand, Azure DevOps attempted to complete the PR, but the required build validation policy (X Pipeline) was not satisfied, so the PR could not be merged.

We also suspect this could be related to a race condition when two PRs attempt to complete around the same time.

Here is the scenario we are investigating:

Two PRs have auto-complete enabled and are waiting for their respective build validations.

Both PRs attempt to complete around the same time.

The first PR completes successfully, and our automation/policy mechanism resets or reconfigures the build validation requirement.

The second PR then attempts auto-completion, but its required build validation policy (X pipeline) is still not satisfied or has been reset to a required state.

Azure DevOps fails the second auto-complete attempt and resets auto-complete for that PR.

We would like to understand whether this sequence is possible and whether Azure DevOps handles concurrent auto-complete attempts in this way.

Questions:

Is resetting auto-complete after a failed completion attempt the default behavior in Azure DevOps?

Can a failed auto-complete attempt occur because of concurrent PR completion attempts or changes to branch policies?

Does Azure DevOps re-evaluate required build validation policies immediately before completing each PR?

Is there any configuration to prevent auto-complete from being reset after a failed attempt, allowing it to retry once the required policies are satisfied?

Is this behavior documented anywhere in Microsoft's official documentation?

I could find documentation explaining how auto-complete works and how required branch policies prevent PR completion, but I couldn't find documentation explicitly explaining when or why Azure DevOps resets the auto-complete setting.

Any clarification from someone familiar with Azure DevOps PR completion internals would be appreciated.

Azure DevOps
0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-25T09:58:53.26+00:00

    A failed required build normally leaves the PR active and waiting; the reset message indicates that an actual completion attempt failed, but Microsoft does not document concurrent PR completion as the cause or provide a setting that preserves auto-complete after every such failure.

    Answers to the specific questions

    1. Is reset the default after a failed completion attempt?
      Azure DevOps can clear auto-complete after a completion attempt returns an error, as your message demonstrates, but the documentation does not define every failure condition that triggers that reset. Importantly, an ordinary failed or pending policy is not documented as automatically clearing auto-complete. Auto-complete is designed to wait until required reviewers and branch policies pass; historical release notes explicitly state that if a build fails or approval is missing, the PR remains active until policies pass.^1^
    2. Can concurrency or policy changes cause it?
      Your sequence is possible at the policy-state level, but the evidence does not establish a race-condition defect. If PR A completes and updates master, PR B’s previously successful build can become invalid depending on its build-expiration setting:
      • Immediately when the protected branch is updated: the policy status becomes failed; an automatic policy queues another build.
      • After n hours: the old result expires when its age exceeds the threshold.
      • Never: a target-branch update does not invalidate the result.
      Thus, two PRs need not modify the policy configuration itself. PR A updating the protected target branch can invalidate PR B’s validation status.^2^ Changing, deleting, or replacing the policy through automation introduces another possible state transition, but Microsoft’s public documentation does not specify transaction ordering between policy updates and simultaneous PR completion jobs. Therefore, the exact reset cannot be conclusively attributed to a race without event timestamps and policy-evaluation records.
    3. Are required policies evaluated at completion?
      Yes, in the supported behavioral sense: completion is permitted only when the PR currently meets all required policies, and existing policies are enforced during completion.^3^ Microsoft does not publicly document the internal locking or exact evaluation sequence immediately before the target-ref update. The API model exposes completionQueueTime, mergeStatus, mergeFailureType, and mergeFailureMessage, showing that completion and merge failure are tracked separately, but these fields do not establish a concurrency cause.^4^
    4. Can reset be disabled so that Azure DevOps retries indefinitely?
      No such setting is documented. After a reset, enable auto-complete again manually or through automation:
         az repos pr update \
           --id <PR_ID> \
           --auto-complete true
      
      Azure DevOps CLI PR commands apply to Azure DevOps Services, not Azure DevOps Server.^3^ Azure Repos does have a narrower retry mechanism for expired policy builds: when all other policies pass and auto-complete is enabled, it can queue up to five expired builds per PR and retries each build only once. That is not a general retry mechanism for failed completion attempts.^5^

    How to verify this incident

    Correlate these timestamps for both PRs:

    1. In each PR, open Overview → View checks and record the build policy’s status, expiration state, and Build ID.
    2. For Azure DevOps Services, capture policy evaluations:
         az repos pr policy list \
           --id <PR_ID> \
           --output table
      
    3. Open Repos → Branches → master → More options → Branch policies → Build validation and record:
      • Required or Optional
      • Automatic or Manual
      • Build-expiration setting
      • Referenced pipeline
    4. Compare:
      • PR A’s completion time
      • the target-branch update
      • PR B’s policy-status change
      • any policy automation update
      • PR B’s completion attempt and reset message
    5. If the incident must be reproduced, subscribe to Pull request merge attempted, Pull request updated, and build-completed service-hook events. Azure DevOps emits a merge-attempt event whether the attempt succeeds or fails, with failure details available for failed attempts.^6^

    If PR B’s build became invalid immediately after PR A updated master, this is consistent with the configured expiration behavior. If the policy remained approved until the merge attempt and no policy configuration changed, retain the service-hook payloads, PR API state, Build ID, and timestamps for an Azure DevOps support case; the public documentation is insufficient to determine the server-side ordering.


    References

    1. Team Foundation Server 2017 Release Notes
    2. Set and manage branch policies
    3. Complete, abandon, or revert pull requests - Azure Repos | Microsoft Learn
    4. GitPullRequest interface-Property Details
    5. Link GitHub commits and pull requests to Azure Boards work items - Sprint 144 Update
    6. Team Foundation Server 2018 Update 2 Release Notes
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.