{"record":{"id":"e4fe4652646c4714","repo":"phacility/phabricator","slug":"unable-to-load-build-target-s","errorCode":null,"errorMessage":"Unable to load build target \"%s\".","messagePattern":"Unable to load build target \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php","lineNumber":45,"sourceCode":"          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $target_id = $args->getArg('target');\n    if (!$target_id) {\n      throw new PhutilArgumentUsageException(\n        pht('Choose a build target to attach the log to with \"--target\".'));\n    }\n\n    $target = id(new HarbormasterBuildTargetQuery())\n      ->setViewer($viewer)\n      ->withIDs(array($target_id))\n      ->executeOne();\n    if (!$target) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unable to load build target \"%s\".',\n          $target_id));\n    }\n\n    $log = HarbormasterBuildLog::initializeNewBuildLog($target);\n    $log->openBuildLog();\n\n    echo tsprintf(\n      \"%s\\n\\n        __%s__\\n\\n\",\n      pht('Opened a new build log:'),\n      PhabricatorEnv::getURI($log->getURI()));\n\n    echo tsprintf(\n      \"%s\\n\",\n      pht('Reading log content from stdin...'));\n\n    $content = file_get_contents('php://stdin');","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php#L27-L63","documentation":"Thrown by 'bin/harbormaster write-log' when --target is supplied but HarbormasterBuildTargetQuery loads no HarbormasterBuildTarget with that ID. The query runs as the CLI viewer (typically an admin), so a miss almost always means no target row with that ID exists in this instance.","triggerScenarios":"Running 'write-log --target 99999' where target 99999 does not exist; an ID copied from another environment; the target was removed when its build was cleaned up.","commonSituations":"Reusing stale target IDs after builds were re-run or garbage-collected; transcription errors when reading the ID from the UI.","solutions":["Confirm the ID from the build target URI (it contains /target/<id>/)","List valid targets with harbormaster.target.search for the owning build","Re-run the build to generate fresh targets if the old ones are gone"],"exampleFix":"# before\n$ echo hi | bin/harbormaster write-log --target 99999\n# after\n$ echo hi | bin/harbormaster write-log --target 33","handlingStrategy":"validation","validationCode":"$target = id(new HarbormasterBuildTargetQuery())\n  ->setViewer($viewer)\n  ->withIDs(array($target_id))\n  ->executeOne();\nif (!$target) {\n  // no such target; get a fresh ID via harbormaster.target.search\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Take target IDs from the target URI (/target/<id>/) of a live build","Re-obtain IDs after re-running builds; old targets may be gone"],"tags":["harbormaster","phabricator","cli","not-found","build-target"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}