Skip to content

create_pull_request fails for same-organization fork because head_repo is omitted #62680

Closed

Description

@DeagleGross

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: true

Repository relationship:

  • Base: dotnet/AspNetCore.Docs
  • Fork: dotnet/AspNetCore.Docs.Automation
  • Both are owned by the dotnet organization.
  • AspNetCore.Docs.Automation is a GitHub fork of AspNetCore.Docs.

Observed run: https://github.com/dotnet/aspnetcore/actions/runs/35735631578/job/106776284741

The safe-output handler successfully:

  1. Applied the generated bundle.
  2. Created dotnet/AspNetCore.Docs.Automation:docs/aspnetcore-pr-68648.
  3. Pushed signed commit 629e6a5c1f1220a3754840d640269b83021b4e52.
  4. 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:

https://github.com/dotnet/AspNetCore.Docs.Automation/tree/docs/aspnetcore-pr-68648

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" and head_repo: "example-org/docs-automation".

Activity

  1. locked and limited conversation to collaborators on Sep 22, 2026
  2. unlocked this conversation on Sep 22, 2026
  3. DeagleGross commented on Sep 28, 2026

    @DeagleGross
    Author

    thanks for doing very quick fixes @pelikhan ! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions