phacility/phabricator · error · Exception

No such repository "%s"!

Error message

No such repository "%s"!

What it means

differential.createrawdiff optionally accepts repositoryPHID to attribute the diff to a repository. When supplied, the PHID is resolved with a viewer-filtered PhabricatorRepositoryQuery; if no repository matches, the method throws a plain Exception with 'No such repository "%s!"' naming the offending PHID.

Source

Thrown at src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php:40

  protected function defineReturnType() {
    return 'nonempty dict';
  }

  protected function execute(ConduitAPIRequest $request) {
    $viewer = $request->getUser();
    $raw_diff = $request->getValue('diff');
    if ($raw_diff === null || !strlen($raw_diff)) {
      throw new Exception(pht('Field "raw_diff" must be non-empty.'));
    }

    $repository_phid = $request->getValue('repositoryPHID');
    if ($repository_phid) {
      $repository = id(new PhabricatorRepositoryQuery())
        ->setViewer($viewer)
        ->withPHIDs(array($repository_phid))
        ->executeOne();
      if (!$repository) {
        throw new Exception(
          pht('No such repository "%s"!', $repository_phid));
      }
    }

    $parser = new ArcanistDiffParser();
    $changes = $parser->parseDiff($raw_diff);
    $diff = DifferentialDiff::newFromRawChanges($viewer, $changes);

    // We're bounded by doing INSERTs for all the hunks and changesets, so
    // estimate the number of inserts we'll require.
    $size = 0;
    foreach ($diff->getChangesets() as $changeset) {
      $hunks = $changeset->getHunks();
      $size += 1 + count($hunks);
    }

    $raw_limit = 10000;
    if ($size > $raw_limit) {

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Resolve the real PHID first with repository.query (by callsigns) and pass that value
  2. Or omit repositoryPHID entirely - the server can often infer or accept the diff without it
  3. Verify the PHID starts with 'PHID-REPO-'
  4. Run the call with a token whose user can see the repository

Example fix

// before
$params = array(
  'diff' => $diff_text,
  'repositoryPHID' => 'XYZ', // callsign, not a PHID
);

// after
$repos = $client->callMethodSynchronous('repository.query', array(
  'callsigns' => array('XYZ'),
));
$params = array(
  'diff' => $diff_text,
  'repositoryPHID' => head($repos)['phid'],
);
Defensive patterns

Strategy: validation

Validate before calling

// Resolve callsign -> PHID with the same token before calling.
$repos = $client->callMethodSynchronous('repository.query',
  array('callsigns' => array($callsign)));
if (!$repos) {
  throw new InvalidArgumentException('Unknown repository '.$callsign);
}
$params['repositoryPHID'] = head($repos)['phid'];
// Or simply omit repositoryPHID.

Try / catch

try {
  $result = $client->callMethodSynchronous('differential.createrawdiff', $params);
} catch (ConduitClientException $ex) {
  if (strpos($ex->getMessage(), 'No such repository') !== false) {
    unset($params['repositoryPHID']); // server can proceed without it
    $result = $client->callMethodSynchronous('differential.createrawdiff', $params);
  } else {
    throw $ex;
  }
}

Prevention

When it happens

Trigger: Passing a repository callsign (e.g. 'XYZ'), a monogram ('rXYZ'), a typo'd PHID, or a PHID of a repository the acting user cannot see; also a repository that was deleted.

Common situations: Tooling that identifies repos by callsign and forgets the conversion step; tokens belonging to users without repository visibility; stale PHIDs cached after a repository was renamed/deleted.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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