{"record":{"id":"69b9b511cbd07259","repo":"phacility/phabricator","slug":"unable-to-load-repository-with-phid-s","errorCode":null,"errorMessage":"Unable to load repository with PHID \"%s\".","messagePattern":"Unable to load repository with PHID \"(.+?)\"\\.","errorType":"exception","errorClass":"PhabricatorWorkerPermanentFailureException","httpStatus":null,"severity":"error","filePath":"src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php","lineNumber":156,"sourceCode":"    }\n\n    $also_phids = $build_target->getFieldValue('repositoryPHIDs');\n    if (!is_array($also_phids)) {\n      $also_phids = array();\n    }\n\n    $all_phids = $also_phids;\n    $all_phids[] = $repository_phid;\n\n    $repositories = id(new PhabricatorRepositoryQuery())\n      ->setViewer($viewer)\n      ->withPHIDs($all_phids)\n      ->execute();\n    $repositories = mpull($repositories, null, 'getPHID');\n\n    foreach ($all_phids as $phid) {\n      if (empty($repositories[$phid])) {\n        throw new PhabricatorWorkerPermanentFailureException(\n          pht(\n            'Unable to load repository with PHID \"%s\".',\n            $phid));\n      }\n    }\n\n    $map = array();\n\n    foreach ($also_phids as $also_phid) {\n      $also_repo = $repositories[$also_phid];\n      $map[$also_repo->getCloneName()] = array(\n        'phid' => $also_repo->getPHID(),\n        'branch' => 'master',\n      );\n    }\n\n    $repository = $repositories[$repository_phid];\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php#L138-L174","documentation":"The step resolves every PHID it plans to clone: 'repository.phid' from the build variables plus the optional 'repositoryPHIDs' ('Also Clone' / additional repositories field). Each PHID must load via PhabricatorRepositoryQuery (as the omnipotent user); any that does not load — i.e. the repository row is gone — triggers this PhabricatorWorkerPermanentFailureException.","triggerScenarios":"A repository referenced by the build (main repository or one of the additional clone repositories) was deleted after the build plan was configured; a stale repository PHID was entered via API/import into the step's repositoryPHIDs field.","commonSituations":"Repository decommissioning without updating build plans; build plan exported from another Phabricator instance keeping old PHIDs; test repositories deleted while plans still referenced them.","solutions":["Edit the build step and remove/re-select the deleted repository in the additional-repositories field.","If the main repository was deleted, the buildable is orphaned — delete or re-point the build plan/buildable.","Audit harbormaster build step configurations for PHIDs of repositories that no longer exist."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate every repository PHID the step will clone:\n$phids = array_merge(\n  array(idx($build_target->getVariables(), 'repository.phid')),\n  (array)$build_target->getFieldValue('repositoryPHIDs'));\n$phids = array_filter($phids);\n$found = id(new PhabricatorRepositoryQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withPHIDs($phids)\n  ->execute();\nif (count($found) !== count($phids)) {\n  // at least one referenced repository no longer exists\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When deleting a repository, remove it from all build steps' additional-repository fields first.","Do not paste raw repository PHIDs into step configuration by hand; use the datasource picker."],"tags":["harbormaster","drydock","repository","phabricator"],"backgroundTag":"dangling-foreign-key-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}