{"record":{"id":"b54770f82994126d","repo":"phacility/phabricator","slug":"repository-phid-s-does-not-exist","errorCode":null,"errorMessage":"Repository PHID \"%s\" does not exist.","messagePattern":"Repository PHID \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php","lineNumber":432,"sourceCode":"        $path = $lease->getAttribute('workingcopy.default');\n        $command_interface->pushWorkingDirectory($path);\n\n        return $command_interface;\n    }\n  }\n\n  private function loadRepositories(array $phids) {\n    $viewer = $this->getViewer();\n\n    $repositories = id(new PhabricatorRepositoryQuery())\n      ->setViewer($viewer)\n      ->withPHIDs($phids)\n      ->execute();\n    $repositories = mpull($repositories, null, 'getPHID');\n\n    foreach ($phids as $phid) {\n      if (empty($repositories[$phid])) {\n        throw new Exception(\n          pht(\n            'Repository PHID \"%s\" does not exist.',\n            $phid));\n      }\n    }\n\n    foreach ($repositories as $repository) {\n      $repository_vcs = $repository->getVersionControlSystem();\n      switch ($repository_vcs) {\n        case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:\n          break;\n        default:\n          throw new Exception(\n            pht(\n              'Repository (\"%s\") has unsupported VCS (\"%s\").',\n              $repository->getPHID(),\n              $repository_vcs));\n      }","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php#L414-L450","documentation":"Thrown by DrydockWorkingCopyBlueprintImplementation::loadRepositories() while activating a working-copy resource or lease. The blueprint reads the 'repositories.map' attribute (a list of specs with a 'phid' key) and loads each referenced repository with PhabricatorRepositoryQuery; if any PHID resolves to no repository object visible to the acting viewer, allocation fails with this exception. It almost always means the map contains a PHID for a repository that was deleted, or one the allocation viewer cannot see due to view policy.","triggerScenarios":"Creating a working-copy resource or activating a lease whose 'repositories.map' attribute contains a repository PHID that is deleted, misspelled, or invisible to the viewer DrydockBlueprintImplementation::getViewer() returns. Concretely: a lease created with attributes {\"repositories.map\": {\"r\": {\"phid\": \"PHID-REPO-deleted\"}}} reaches activateResource() (line 203) or activateLease() (line 277) and loadRepositories() finds no match.","commonSituations":"A Diffusion repository was deleted or migrated after the lease attributes or automation (e.g. Harbormaster/operations) were configured; the repository's view policy was tightened so the worker viewer can no longer see it; a hand-edited JSON attributes file passed to `bin/drydock lease --attributes` contains a stale or truncated PHID.","solutions":["Look up the repository by callsign/name in Diffusion and copy its current PHID from the repository detail page, then update the repositories.map attribute/JSON to use it.","Check whether the repository still exists: if it was deleted, remove its entry from the map or point the lease at a replacement repository.","If the repository exists, verify the acting viewer can see it (repository view policy vs. the user/daemon running allocation) and loosen the policy or run allocation as a viewer with access.","Validate the map before creating leases: resolve every PHID with PhabricatorRepositoryQuery using the same viewer and fail early in your own code.","Re-run the lease/resource allocation once the map contains only resolvable PHIDs."],"exampleFix":"// before (attributes passed to `bin/drydock lease --attributes -`)\n{\"repositories.map\": {\"src\": {\"phid\": \"PHID-REPO-xz3deadbeef\"}}}\n\n// after (PHID of an existing, visible Git repository)\n{\"repositories.map\": {\"src\": {\"phid\": \"PHID-REPO-current-valid\"}}}","handlingStrategy":"validation","validationCode":"$phids = ipull($attributes['repositories.map'], 'phid');\n$found = id(new PhabricatorRepositoryQuery())\n  ->setViewer($viewer)\n  ->withPHIDs($phids)\n  ->execute();\n$missing = array_diff($phids, mpull($found, 'getPHID'));\nif ($missing) {\n  throw new InvalidArgumentException(\n    'Unresolvable repository PHIDs: '.implode(', ', $missing));\n}","typeGuard":"function isValidRepositoryPHID($viewer, $phid) {\n  return (bool)id(new PhabricatorRepositoryQuery())\n    ->setViewer($viewer)\n    ->withPHIDs(array($phid))\n    ->executeOne();\n}","tryCatchPattern":null,"preventionTips":["Never hand-type repository PHIDs; read them from the repository object or the Diffusion UI.","Re-resolve every PHID in lease attributes right before creating the lease, with the same viewer that will run allocation.","When deleting or migrating a Diffusion repository, grep automation config and blueprint/lease templates for its PHID."],"tags":["drydock","phabricator","repository","phid","blueprint","working-copy"],"backgroundTag":"invalid-phid-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}