phacility/phabricator · warning · PhutilArgumentUsageException

Revision "%s" does not exist.

Error message

Revision "%s" does not exist.

What it means

In attach-commit, the second positional argument is resolved with PhabricatorObjectQuery->withNames()->executeOne(); if no object matches the given name, the workflow throws this usage exception. Only names the viewer can see resolve, so an invisible or mistyped revision name is indistinguishable from a nonexistent one.

Source

Thrown at src/applications/differential/management/PhabricatorDifferentialAttachCommitWorkflow.php:48

    $commit_name = head($argv);
    $revision_name = last($argv);

    $commit = id(new DiffusionCommitQuery())
      ->setViewer($viewer)
      ->withIdentifiers(array($commit_name))
      ->executeOne();
    if (!$commit) {
      throw new PhutilArgumentUsageException(
        pht('Commit "%s" does not exist.', $commit_name));
    }

    $revision = id(new PhabricatorObjectQuery())
      ->setViewer($viewer)
      ->withNames(array($revision_name))
      ->executeOne();

    if (!$revision) {
      throw new PhutilArgumentUsageException(
        pht('Revision "%s" does not exist.', $revision_name));
    }

    if (!($revision instanceof DifferentialRevision)) {
      throw new PhutilArgumentUsageException(
        pht('Object "%s" must be a Differential revision.', $revision_name));
    }

    // Reload the revision to get the active diff.
    $revision = id(new DifferentialRevisionQuery())
      ->setViewer($viewer)
      ->withIDs(array($revision->getID()))
      ->needActiveDiffs(true)
      ->executeOne();

    $differential_phid = id(new PhabricatorDifferentialApplication())
      ->getPHID();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use the canonical monogram form D<id> (e.g., D456) as the second argument
  2. Pre-validate the name with './bin/search' or a Conduit 'phid.lookup' call before attaching
  3. If the revision is real but hidden, run as a user who can see it (or an admin)
  4. Check for trailing whitespace or shell mangling of the argument

Example fix

# before
phabricator/ $ ./bin/differential attach-commit rP703dcf5 456
Usage Exception: Revision "456" does not exist.

# after
phabricator/ $ ./bin/differential attach-commit rP703dcf5 D456
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate the revision name resolves to a visible revision:
$result = id(new PhabricatorObjectQuery())
  ->setViewer($viewer)
  ->withNames(array($revision_name))
  ->executeOne();
if (!($result instanceof DifferentialRevision)) {
  // fix the name before invoking attach-commit
}

Type guard

function isDifferentialMonogram($name) {
  return is_string($name) && preg_match('/^D\d+$/', $name);
}

Try / catch

try {
  $workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
  // 'Revision ... does not exist' -> re-check monogram/policy, do not retry blindly.
}

Prevention

When it happens

Trigger: Passing a bare number ('456') instead of the D-prefixed monogram 'D456'; passing a revision PHID where a name is expected; typo in the monogram; the revision exists but is hidden from the acting user by view policy; passing a URI instead of the monogram.

Common situations: Scripts piping raw IDs from another system into the command; new operators unfamiliar with the D-monogram convention; restricted-policy revisions and non-admin CLI users (CLI runs as the console user unless configured otherwise).

Related errors


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