phacility/phabricator · error · Exception

Unable to determine how to clone the repository for this bui

Error message

Unable to determine how to clone the repository for this buildable: it is not associated with a tracked repository.

What it means

buildRepositoryMap() reads the 'repository.phid' variable from the build target's build variables; when it is absent, the step cannot know which repository to clone and throws. The variable is only populated for buildables attached to a tracked Phabricator repository (e.g. a Differential revision with a repository set, or a repository commit).

Source

Thrown at src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php:134

        'name' => pht('Use Blueprints'),
        'type' => 'blueprints',
        'required' => true,
      ),
      'repositoryPHIDs' => array(
        'name' => pht('Also Clone'),
        'type' => 'datasource',
        'datasource.class' => 'DiffusionRepositoryDatasource',
      ),
    );
  }

  private function buildRepositoryMap(HarbormasterBuildTarget $build_target) {
    $viewer = PhabricatorUser::getOmnipotentUser();
    $variables = $build_target->getVariables();

    $repository_phid = idx($variables, 'repository.phid');
    if (!$repository_phid) {
      throw new Exception(
        pht(
          'Unable to determine how to clone the repository for this '.
          'buildable: it is not associated with a tracked repository.'));
    }

    $also_phids = $build_target->getFieldValue('repositoryPHIDs');
    if (!is_array($also_phids)) {
      $also_phids = array();
    }

    $all_phids = $also_phids;
    $all_phids[] = $repository_phid;

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

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Associate the buildable object with a tracked repository (set the repository on the Differential revision).
  2. Restrict the build plan so it only runs against buildables of repository-backed objects.
  3. If repository detection failed, fix the revision's repository field and re-run the build.
Defensive patterns

Strategy: validation

Validate before calling

// Check the variables a working-copy step depends on, before running:
$variables = $build_target->getVariables();
if (empty($variables['repository.phid'])) {
  // buildable is not attached to a tracked repository - do not run the step
}

Prevention

When it happens

Trigger: Running the 'Lease Working Copy' step on a buildable that is not associated with a repository: a Differential revision with no repository set (or a revision whose repository cannot be determined), or a build plan applied to an object type that never populates 'repository.phid'.

Common situations: Revisions imported without repository detection; builds triggered on paste/mock objects by an over-broad build plan; repository detection disabled or failing for the revision's callsign.

Related errors


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