{"record":{"id":"ee35744c92ca608c","repo":"phacility/phabricator","slug":"harbormaster-build-target-s-does-not-exist","errorCode":null,"errorMessage":"Harbormaster build target \"%s\" does not exist.","messagePattern":"Harbormaster build target \"(.+?)\" does not exist\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/harbormaster/controller/HarbormasterBuildkiteHookController.php","lineNumber":50,"sourceCode":"      throw new Exception(\n        pht(\n          'Expected \"%s\" property to contain a dictionary.',\n          'build.meta_data'));\n    }\n\n    $target_phid = idx($meta_data, 'buildTargetPHID');\n    if (!$target_phid) {\n      return $this->newHookResponse(pht('OK: No Harbormaster target PHID.'));\n    }\n\n    $viewer = PhabricatorUser::getOmnipotentUser();\n    $target = id(new HarbormasterBuildTargetQuery())\n      ->setViewer($viewer)\n      ->withPHIDs(array($target_phid))\n      ->needBuildSteps(true)\n      ->executeOne();\n    if (!$target) {\n      throw new Exception(\n        pht(\n          'Harbormaster build target \"%s\" does not exist.',\n          $target_phid));\n    }\n\n    $step = $target->getBuildStep();\n    $impl = $step->getStepImplementation();\n    if (!($impl instanceof HarbormasterBuildkiteBuildStepImplementation)) {\n      throw new Exception(\n        pht(\n          'Harbormaster build target \"%s\" is not a Buildkite build step. '.\n          'Only Buildkite steps may be updated via the Buildkite hook.',\n          $target_phid));\n    }\n\n    $webhook_token = $impl->getSetting('webhook.token');\n    $request_token = $request->getHTTPHeader('X-Buildkite-Token');\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/controller/HarbormasterBuildkiteHookController.php#L32-L68","documentation":"The Buildkite webhook resolved a buildTargetPHID from build.meta_data and loaded it with HarbormasterBuildTargetQuery under the omnipotent user, but no build target with that PHID exists. The reference from the external system (Buildkite) to the internal Harbormaster entity is dangling.","triggerScenarios":"A webhook replayed long after the build (and its targets) were garbage-collected or deleted; a stale pipeline configuration carrying an old PHID; a hand-crafted payload with a typo'd or invented PHID; the buildable/plan being rebuilt so old targets vanished while Buildkite still reports for them.","commonSituations":"Retrying old webhook deliveries from the Buildkite UI; aggressive Harbormaster garbage collection (phabricator garbage-collector) removing old build data; copy-pasting payloads between test and production installs where PHIDs differ.","solutions":["Trigger a fresh build from Harbormaster so a new target exists, and make sure the pipeline picks up the new PHID (meta-data is per-build; old deliveries cannot be applied).","Verify the PHID format and install: PHID-HMBT- values are per-instance; a payload from another install will never resolve.","If builds are being GC'd before CI reports, raise the retention for old builds/logs in the garbage collector config.","Ignore the delivery in Buildkite — the error is expected for stale events and the new build will report correctly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before applying a webhook, confirm the target still exists:\n$target = id(new HarbormasterBuildTargetQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withPHIDs(array($target_phid))\n  ->executeOne();\nif (!$target) { /* drop the stale delivery */ }","typeGuard":null,"tryCatchPattern":"try {\n  $this->updateTarget($target, $payload);\n} catch (Exception $e) {\n  // Stale PHID from an old build: log and acknowledge the delivery,\n  // do not retry — the target is gone for good.\n  phlog($e);\n  return newHookResponse(pht('OK: Stale target.'));\n}","preventionTips":["Treat webhook PHIDs as ephemeral references valid only for the life of the build; never cache them across builds.","Raise Harbormaster garbage-collection retention if CI reports can arrive after targets are collected.","Do not replay webhook deliveries across installs or after builds are deleted."],"tags":["harbormaster","buildkite","webhook","stale-reference","phid"],"backgroundTag":"stale-entity-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}