phacility/phabricator · warning · PhutilArgumentUsageException

Commit "%s" does not exist.

Error message

Commit "%s" does not exist.

What it means

In attach-commit, the commit positional argument is resolved through DiffusionCommitQuery->withIdentifiers()->executeOne(); when no visible commit matches, the workflow throws this usage exception. It means the identifier did not resolve to any imported commit under the viewer's policies, not merely that the string is malformed.

Source

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

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();

    $argv = $args->getArg('argv');
    if (count($argv) !== 2) {
      throw new PhutilArgumentUsageException(
        pht('Specify a commit and a revision to attach it to.'));
    }

    $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));
    }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use the fully qualified identifier (full 40-char Git SHA or hg full hash) or the r<REPO><short-hash> monogram so the query resolves unambiguously
  2. Confirm the commit is imported: run './bin/repository discover --repoid <id>' then './bin/repository importing' and let daemons finish parsing
  3. Run the command as an administrator or a viewer who can see the repository
  4. Verify the hash exists in the upstream repo (git rev-parse <hash>) before retrying

Example fix

# before
phabricator/ $ ./bin/differential attach-commit abc12 D456
Usage Exception: Commit "abc12" does not exist.

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

Strategy: validation

Validate before calling

// Verify the commit resolves for this viewer before attaching:
phabricator/ $ ./bin/repository importing   # confirm nothing pending
phabricator/ $ ./bin/differential attach-commit rP703dcf56... D456  # full identifier

Type guard

// Use unambiguous identifiers only: full VCS hash or r<REPO><hash> monogram
preg_match('/^r[A-Z]+[0-9a-f]{7,40}$|^[0-9a-f]{40}$/', $commit_name)

Try / catch

try {
  $workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
  // Missing commit: check discovery/import state, then retry with a full hash.
}

Prevention

When it happens

Trigger: Passing an ambiguous short hash without repository context (DiffusionCommitQuery needs enough of the hash or repository scoping to resolve it); the commit exists in the repository but has not been discovered/imported yet; the viewer cannot see the repository; typo in the hash; using a branch name instead of a commit identifier.

Common situations: Fresh clones where './bin/repository discover' has not run; repositories stuck in an importing state (check ./bin/repository importing); running the workflow as a user restricted by repository view policies; copy-pasting truncated hashes from a terminal.

Related errors


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