Repository navigation
Description
Summary
The create_pull_request safe-output handler successfully pushes a branch to a configured fork, but GitHub rejects the subsequent PR creation when the target repository and fork are owned by the same organization.
The handler qualifies head as owner:branch, but doesn't send the REST API's head_repo field. GitHub requires head_repo for cross-repository pull requests when both repositories are owned by the same organization.
Reproduction
Workflow configuration:
safe-outputs:
create-pull-request:
target-repo: dotnet/AspNetCore.Docs
head-repo: dotnet/AspNetCore.Docs.Automation
head-github-token: ${{ steps.some-app-token.outputs.token }}
base-branch: main
preserve-branch-name: trueRepository relationship:
- Base:
dotnet/AspNetCore.Docs - Fork:
dotnet/AspNetCore.Docs.Automation - Both are owned by the
dotnetorganization. AspNetCore.Docs.Automationis a GitHub fork ofAspNetCore.Docs.
The safe-output handler successfully:
- Applied the generated bundle.
- Created
dotnet/AspNetCore.Docs.Automation:docs/aspnetcore-pr-68648. - Pushed signed commit
629e6a5c1f1220a3754840d640269b83021b4e52. - Confirmed one commit exists relative to
AspNetCore.Docs:main.
PR creation then failed:
Validation Failed: {"resource":"PullRequest","field":"head","code":"invalid"}
The pushed branch is visible at:
Root cause
actions/setup/js/create_pull_request.cjs correctly resolves the configured head-repo and formats a cross-repository head as:
`${pushRepoParts.owner}:${branch}`It then calls createOrUpdatePullRequest with that value.
actions/setup/js/create_or_update_pull_request.cjs submits:
githubClient.rest.pulls.create({
owner: repoParts.owner,
repo: repoParts.repo,
title,
body,
head: branchName,
base: baseBranch,
draft,
})No head_repo is passed.
For this topology, head becomes:
dotnet:docs/aspnetcore-pr-68648
Because both repositories are owned by dotnet, that value doesn't distinguish AspNetCore.Docs.Automation from AspNetCore.Docs.
GitHub's REST schema documents head_repo as required for cross-repository pull requests when both repositories are owned by the same organization:
The name of the repository where the changes in the pull request were made. This field is required for cross-repository pull requests if both repositories are owned by the same organization.
Expected behavior
When head-repo differs from target-repo, pass the configured full repository name to the REST request:
githubClient.rest.pulls.create({
// ...
head: `${headOwner}:${branchName}`,
head_repo: "dotnet/AspNetCore.Docs.Automation",
})The existing different-owner fork and same-repository behavior should remain unchanged.
Suggested coverage
Add a create_pull_request handler test for:
- base repository
example-org/docs; - head repository
example-org/docs-automation; - both repositories owned by the same organization;
- generated request contains both
head: "example-org:branch"andhead_repo: "example-org/docs-automation".
Activity
DeagleGross commentedon Sep 28, 2026
thanks for doing very quick fixes @pelikhan ! <3