Resolve a renamed fork's head when checking a pull request's provenance - #720
Draft
coopernetes wants to merge 1 commit into
Draft
coopernetes wants to merge 1 commit into
coopernetes wants to merge 1 commit into
Conversation
With require-validated-head on, opening a pull request from a fork whose name differs from the upstream's (RBC/mlflow-mlflow of mlflow/mlflow) was refused through the SCM API proxy with "Could not resolve head branch ... to a commit upstream". The head resolvers for GitHub and Gitea/Forgejo looked the branch up in <head-owner>/<upstream-name>, which only exists when the fork kept the upstream's name. The head repository is now identified from the fork relationship: GitHub's headRepositoryId when sent, then the owner's same-name repository only if it is a fork of the upstream, then the upstream's own parent when the owner owns it, then a search of the owner's forks capped at a few pages. The upstream's fork network is never listed. A head that cannot be identified is still refused. GitLab is unaffected: its create request already addresses the source project. closes #719 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
require-validated-headon,gh pr createfrom a fork renamed away from the upstream's name (e.g.RBC/coopernetes-test-repoofcoopernetes/test-repo) was refused with "Could not resolve head branch ... to a commit upstream". The GitHub and Gitea/Forgejo head resolvers looked the branch up in<head-owner>/<upstream-name>.The head repository is now identified by fork relationship, in this order:
input.headRepositoryId, when sent (GitHub only; Gitea/Forgejo's API has no equivalent). Anowner:prefix that disagrees with that repository's owner is refused.repositoryOwner { repositories(isFork: true) }, 100 per page; Gitea/Forgejo:/repos/search?uid=&exclusive=true&mode=fork, 50 per page), matching on parent.The upstream's fork network is never listed. Anything unidentified still resolves empty and is refused as before. GitLab is unaffected:
mr createalready POSTs to the source project's own URL, and the resolver reads the branch there.ScmApiHeadValidationFilter.HeadShaResolutionnow also receives the parsed request body, so the GitHub resolver can readheadRepositoryId.Tests:
GitHubHeadShaResolverTestandForgejoHeadShaResolverTestcover each resolution step, same-name non-fork, same-name fork of another repo, cursor paging, the page cap, unknown owner, and an upstream error stopping resolution. The wiring change inFogwallServletRegistraris compile-checked only; no e2e covers a renamed fork.Decisions for review
gh api graphqland the Gitea/Forgejo endpoints against codeberg.org, but no PR was opened through a running fogwall.🤖 Generated with Claude Code