Skip to content

create-pr: base_commit from Stage 1 may become unreachable after target branch force-push #193

@jamesadevine

Description

@jamesadevine

Problem

When self.base_commit is present (recorded at patch generation time), it's used as "parents": [base_commit] in the ADO Push API payload. The merge-base is by definition an ancestor of the target branch, so this is semantically correct.

However, if the target branch was force-pushed after Stage 1 ran, the merge-base SHA might no longer be reachable in ADO's history — the push would fail with a cryptic HTTP 400.

The existing fallback (resolving live target branch HEAD when base_commit is None) doesn't help here because base_commit is Some.

Suggested Fix

If the push fails with a 400 and base_commit was from Stage 1, retry by falling back to the live ADO refs API resolution (same as the None path).

Context

Low probability in practice — requires a force-push to the target branch between Stage 1 and Stage 2. But worth checking first if unexpected 400 errors appear in production.

Identified in PR #155 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions