Skip to content

[aw]: Follow-up to #1413 / #1425: create-pull-request worktree fails — the prepare-pr-base step runs in the Agent job, but the executor runs in the SafeOutputs job (standalone target) #1453

Description

@dschmittwilken

Submission requirements

  • I generated this issue with an agent that used .github/agents/ado-aw.agent.md.
  • I reviewed the generated issue and confirm it is being filed directly in githubnext/ado-aw.

Problem summary

#1425 (v0.43.0) fixed the shallow-clone diff-base problem by adding a host-side
"Prepare create-pull-request base ref (fetch/deepen)" step that fetches the target branch
into refs/remotes/origin/<target>. On the standalone target this doesn't work, because the
prepare step and the create-pull-request executor run in different jobs with different
checkouts
, and the fetched ref doesn't carry across them.

In the generated standalone lock:

  • The "Prepare create-pull-request base ref (fetch/deepen)" step
    (node prepare-pr-base.js --repo-dir "$(Build.SourcesDirectory)" --target-branch '<target>')
    is emitted in the Agent job. It fetches refs/remotes/origin/<target> into the Agent
    job's checkout.
  • ado-aw execute (which runs create-pull-request) is emitted in the SafeOutputs
    job — a separate ADO job with its own fresh checkout: self. On a shallow-default pool that
    checkout has neither origin/<target> nor <target>.

Each ADO job gets an isolated checkout, so the ref prepared in the Agent job is absent when the
executor builds its worktree in the SafeOutputs job. git worktree add then fails trying both
the origin/-prefixed and bare names.

Reproduction details

Environment: standalone target, self-hosted pool whose default git fetch is shallow;
safe-outputs.create-pull-request with target-branch: develop.

Run to the SafeOutputs stage. The executor log (ado_aw::safe_outputs::create_pull_request):

Target branch from config: develop
Source ref: refs/heads/agent/<...>, Target ref: refs/heads/develop
Git repository directory: /mnt/vss/_work/1/s
Creating worktree at: /tmp/.../worktree
Worktree creation with origin/ prefix failed, trying without: fatal: invalid reference: origin/develop
Failed to create worktree: fatal: invalid reference: develop

Both origin/develop and develop are invalid in the SafeOutputs job's checkout — the
Agent-job prepare step's fetch is not visible here. (The comment-on-work-item and
update-work-item safe outputs in the same executor run are unaffected; only the git/worktree
path needs the ref.)

Proposed next step

Emit the target-ref preparation in the same job/checkout as the executor:

(a) Emit the "Prepare create-pull-request base ref (fetch/deepen)" step in the SafeOutputs
job, immediately before ado-aw execute — not (only) in the Agent job. (Simplest; mirrors what
already exists, just in the right job.)

(b) Or make the executor self-sufficient: before git worktree add, have
create_pull_request fetch the target branch into its own working dir
(git fetch --no-tags origin +refs/heads/<target>:refs/remotes/origin/<target>, deepening as
needed) — so it never depends on a prepare step in another job.

Either removes the last blocker for shallow-pool standalone pipelines. Today the only workaround
is a post-compile lock edit that injects the fetch into the SafeOutputs job before
ado-aw execute — which re-introduces the exact lock-patching #1425 set out to remove.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrustPull requests that update rust code

    Type

    No type

    Fields

    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