phacility/phabricator · error · Exception
Commit "%s" is not an ancestor of any branch head, so it can
Error message
Commit "%s" is not an ancestor of any branch head, so it can not be built with Buildkite.
What it means
getBuildkiteBranch() (PhabricatorRepositoryCommit.php:741-769) runs diffusion.branchquery with 'contains' => commit identifier to find branch heads that contain the commit, then returns 'refs/heads/<branch>' for Buildkite. If no branch head has the commit as an ancestor, there is no ref Buildkite can build, so it throws.
Source
Thrown at src/applications/repository/storage/PhabricatorRepositoryCommit.php:759
public function getBuildkiteBranch() {
$viewer = PhabricatorUser::getOmnipotentUser();
$repository = $this->getRepository();
$branches = DiffusionQuery::callConduitWithDiffusionRequest(
$viewer,
DiffusionRequest::newFromDictionary(
array(
'repository' => $repository,
'user' => $viewer,
)),
'diffusion.branchquery',
array(
'contains' => $this->getCommitIdentifier(),
'repository' => $repository->getPHID(),
));
if (!$branches) {
throw new Exception(
pht(
'Commit "%s" is not an ancestor of any branch head, so it can not '.
'be built with Buildkite.',
$this->getCommitIdentifier()));
}
$branch = head($branches);
return 'refs/heads/'.$branch['shortName'];
}
public function getBuildkiteCommit() {
return $this->getCommitIdentifier();
}
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
View on GitHub (pinned to 5720a38cfe)
Solutions
- Ensure the commit is pushed as (or merged into) a real branch head before the Buildkite step runs, e.g. publish the Diff or push the branch
- Resync the mirror so the branch query sees current refs: bin/repository update / re-run discovery for the repository
- Configure the build plan so the Buildkite step only runs on final (published) builds rather than draft builds
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: ask which branches contain the commit, mirroring the step.
$branches = DiffusionQuery::callConduitWithDiffusionRequest(
PhabricatorUser::getOmnipotentUser(),
DiffusionRequest::newFromDictionary(array(
'repository' => $repository,
'user' => PhabricatorUser::getOmnipotentUser(),
)),
'diffusion.branchquery',
array(
'contains' => $commit->getCommitIdentifier(),
'repository' => $repository->getPHID(),
));
if (!$branches) {
// not on any branch head: do not run the Buildkite step yet
} Type guard
function isOnBranchHead(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
// Cheap heuristic: tag-only or unpublished commits are risky; verify via
// diffusion.branchquery 'contains' before building.
return (bool)DiffusionBranchQuery::callConduitWithDiffusionRequest(
null, null, 'diffusion.branchquery',
array('contains' => $commit->getCommitIdentifier()));
} Try / catch
try {
$branch = $commit->getBuildkiteBranch();
} catch (Exception $ex) {
// Commit not on any branch head (deleted branch, tag-only, unpublished
// diff): fail the build target with the message; retry after the commit
// is pushed to a branch.
$build_target->log($ex->getMessage());
throw new HarbormasterBuildFailureException();
} Prevention
- Publish Diffs (push real branches) before running Buildkite builds
- Keep mirrors synced (bin/repository update) so branch queries see current refs
- Restrict Buildkite steps to final/published builds in the build plan configuration
When it happens
Trigger: A Buildkite build step runs on a buildable whose commit is reachable only from tags, pushed under refs/diff/* or another non-branch ref, on a branch deleted/force-pushed before the build executed, or not pushed to the remote at all (pre-publish draft builds).
Common situations: Building Differential patch/Diff branches that were never pushed as real branches; racing a force-push or branch deletion in a fast-moving mirror; tag-only release commits; stale mirrors whose refs have not been updated yet.
Related errors
- This commit ("%s") is associated with a hosted repository ("
- This commit ("%s") is associated with a repository ("%s") wh
- This object does not support builds with Buildkite.
- Unable to load API token ("%s")!
- Buildkite did not return a "%s"!
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/a60f0c8488f02a59.
Report an issue: GitHub.