phacility/phabricator · error · Exception

Repository PHID "%s" does not exist.

Error message

Repository PHID "%s" does not exist.

What it means

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.

Source

Thrown at src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php:432

        $path = $lease->getAttribute('workingcopy.default');
        $command_interface->pushWorkingDirectory($path);

        return $command_interface;
    }
  }

  private function loadRepositories(array $phids) {
    $viewer = $this->getViewer();

    $repositories = id(new PhabricatorRepositoryQuery())
      ->setViewer($viewer)
      ->withPHIDs($phids)
      ->execute();
    $repositories = mpull($repositories, null, 'getPHID');

    foreach ($phids as $phid) {
      if (empty($repositories[$phid])) {
        throw new Exception(
          pht(
            'Repository PHID "%s" does not exist.',
            $phid));
      }
    }

    foreach ($repositories as $repository) {
      $repository_vcs = $repository->getVersionControlSystem();
      switch ($repository_vcs) {
        case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
          break;
        default:
          throw new Exception(
            pht(
              'Repository ("%s") has unsupported VCS ("%s").',
              $repository->getPHID(),
              $repository_vcs));
      }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. 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.
  2. Check whether the repository still exists: if it was deleted, remove its entry from the map or point the lease at a replacement repository.
  3. 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.
  4. Validate the map before creating leases: resolve every PHID with PhabricatorRepositoryQuery using the same viewer and fail early in your own code.
  5. Re-run the lease/resource allocation once the map contains only resolvable PHIDs.

Example fix

// before (attributes passed to `bin/drydock lease --attributes -`)
{"repositories.map": {"src": {"phid": "PHID-REPO-xz3deadbeef"}}}

// after (PHID of an existing, visible Git repository)
{"repositories.map": {"src": {"phid": "PHID-REPO-current-valid"}}}
Defensive patterns

Strategy: validation

Validate before calling

$phids = ipull($attributes['repositories.map'], 'phid');
$found = id(new PhabricatorRepositoryQuery())
  ->setViewer($viewer)
  ->withPHIDs($phids)
  ->execute();
$missing = array_diff($phids, mpull($found, 'getPHID'));
if ($missing) {
  throw new InvalidArgumentException(
    'Unresolvable repository PHIDs: '.implode(', ', $missing));
}

Type guard

function isValidRepositoryPHID($viewer, $phid) {
  return (bool)id(new PhabricatorRepositoryQuery())
    ->setViewer($viewer)
    ->withPHIDs(array($phid))
    ->executeOne();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/b54770f82994126d. Report an issue: GitHub.