{"record":{"id":"a60f0c8488f02a59","repo":"phacility/phabricator","slug":"commit-s-is-not-an-ancestor-of-any-branch-head","errorCode":null,"errorMessage":"Commit \"%s\" is not an ancestor of any branch head, so it can not be built with Buildkite.","messagePattern":"Commit \"(.+?)\" is not an ancestor of any branch head, so it can not be built with Buildkite\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/repository/storage/PhabricatorRepositoryCommit.php","lineNumber":759,"sourceCode":"  public function getBuildkiteBranch() {\n    $viewer = PhabricatorUser::getOmnipotentUser();\n    $repository = $this->getRepository();\n\n    $branches = DiffusionQuery::callConduitWithDiffusionRequest(\n      $viewer,\n      DiffusionRequest::newFromDictionary(\n        array(\n          'repository' => $repository,\n          'user' => $viewer,\n        )),\n      'diffusion.branchquery',\n      array(\n        'contains' => $this->getCommitIdentifier(),\n        'repository' => $repository->getPHID(),\n      ));\n\n    if (!$branches) {\n      throw new Exception(\n        pht(\n          'Commit \"%s\" is not an ancestor of any branch head, so it can not '.\n          'be built with Buildkite.',\n          $this->getCommitIdentifier()));\n    }\n\n    $branch = head($branches);\n\n    return 'refs/heads/'.$branch['shortName'];\n  }\n\n  public function getBuildkiteCommit() {\n    return $this->getCommitIdentifier();\n  }\n\n\n/* -(  PhabricatorCustomFieldInterface  )------------------------------------ */\n","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/storage/PhabricatorRepositoryCommit.php#L741-L777","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight: ask which branches contain the commit, mirroring the step.\n$branches = DiffusionQuery::callConduitWithDiffusionRequest(\n  PhabricatorUser::getOmnipotentUser(),\n  DiffusionRequest::newFromDictionary(array(\n    'repository' => $repository,\n    'user' => PhabricatorUser::getOmnipotentUser(),\n  )),\n  'diffusion.branchquery',\n  array(\n    'contains' => $commit->getCommitIdentifier(),\n    'repository' => $repository->getPHID(),\n  ));\nif (!$branches) {\n  // not on any branch head: do not run the Buildkite step yet\n}","typeGuard":"function isOnBranchHead(\n  PhabricatorRepository $repository,\n  PhabricatorRepositoryCommit $commit) {\n  // Cheap heuristic: tag-only or unpublished commits are risky; verify via\n  // diffusion.branchquery 'contains' before building.\n  return (bool)DiffusionBranchQuery::callConduitWithDiffusionRequest(\n    null, null, 'diffusion.branchquery',\n    array('contains' => $commit->getCommitIdentifier()));\n}","tryCatchPattern":"try {\n  $branch = $commit->getBuildkiteBranch();\n} catch (Exception $ex) {\n  // Commit not on any branch head (deleted branch, tag-only, unpublished\n  // diff): fail the build target with the message; retry after the commit\n  // is pushed to a branch.\n  $build_target->log($ex->getMessage());\n  throw new HarbormasterBuildFailureException();\n}","preventionTips":["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"],"tags":["phabricator","harbormaster","buildkite","ci-integration","git-refs","php"],"backgroundTag":"commit-not-on-branch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}