Skip to content

Fix PR creation on GitHub App auth path (pass --head to gh pr create)#1445

Open
jingjingjia-ms wants to merge 1 commit into
mainfrom
jingjingjia/fix-app-auth-pr-create-head
Open

Fix PR creation on GitHub App auth path (pass --head to gh pr create)#1445
jingjingjia-ms wants to merge 1 commit into
mainfrom
jingjingjia/fix-app-auth-pr-create-head

Conversation

@jingjingjia-ms

@jingjingjia-ms jingjingjia-ms commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Build 225234 failed on all 6 microsoft/Agents-M365Copilot generation jobs at the Create Pull Request step with:

aborted: you must first push the current branch to a remote, or use the --head flag
Pull Request Created successfully.
##[error]PowerShell exited with code '1'.

The push actually succeeded — the branches (ccs-{dotnet,python,typescript}/{v1.0,beta}/pipelinebuild/225234) exist on the remote, each ahead of main with the generated commit — but no PRs were created, and the log misleadingly printed "Pull Request Created successfully."

Root cause

The GitHub App auth path (useGitHubAppAuth: true, used only by Agents-M365Copilot) clones with git clone --depth 1. --depth 1 implies --single-branch, so remote.origin.fetch only tracks the base branch. After pushing the generated feature branch, no refs/remotes/origin/<branch> tracking ref exists locally. gh pr create (invoked without --head) detects the pushed head via that tracking ref, doesn't find it, and aborts — even though the branch is on the remote. The other SDK repos use the ADO checkout: task, which wires up full tracking refs, so they were unaffected.

Fix

  • scripts/create-pull-request.ps1: pass -H $env:BranchName (bypasses the tracking-ref auto-detection) and -R $env:RepoName to gh pr create; fail the step on a non-zero exit code instead of unconditionally printing success.
  • language-generation-kiota.yml: thread BranchName into the create-pull-request.ps1 step env: so the head branch is available (shared step — both auth paths get the more robust --head/-R invocation).
Microsoft Reviewers: Open in CodeFlow

The GitHub App auth generation path clones repos with `git clone --depth 1`,
which implies --single-branch and only tracks the base branch. After pushing
the generated feature branch, no `refs/remotes/origin/<branch>` tracking ref
exists locally, so `gh pr create` (which auto-detects the pushed head via that
ref) aborts with "you must first push the current branch to a remote, or use
the --head flag" even though the push succeeded.

- create-pull-request.ps1: pass `-H $env:BranchName` and `-R $env:RepoName` to
  `gh pr create`, and fail the step on a non-zero exit code instead of always
  printing "Pull Request Created successfully."
- language-generation-kiota.yml: thread `BranchName` into the
  create-pull-request.ps1 step env so the head branch is available.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jingjingjia-ms jingjingjia-ms requested a review from a team as a code owner July 1, 2026 03:14
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.

1 participant