phacility/phabricator · error · Exception

Unable to retrieve CommitRef record for commit "%s".

Error message

Unable to retrieve CommitRef record for commit "%s".

What it means

In the same newCommitRef() call, internal.commit.search returned exactly one record, but its fields.ref payload (the raw VCS ref: message, author, committer, hash) is missing or empty (PhabricatorRepositoryCommit.php:569-577). The ref payload is produced by the commit message parser, so the usual cause is requesting the ref of a commit that has been discovered but not yet parsed/imported.

Source

Thrown at src/applications/repository/storage/PhabricatorRepositoryCommit.php:573

        pht(
          'Unable to retrieve details for commit "%s"!',
          $commit_display));
    }

    if (count($result['data']) !== 1) {
      throw new Exception(
        pht(
          'Got too many results (%s) for commit "%s", expected %s.',
          phutil_count($result['data']),
          $commit_display,
          1));
    }

    $record = head($result['data']);
    $ref_record = idxv($record, array('fields', 'ref'));

    if (!$ref_record) {
      throw new Exception(
        pht(
          'Unable to retrieve CommitRef record for commit "%s".',
          $commit_display));
    }

    return DiffusionCommitRef::newFromDictionary($ref_record);
  }

/* -(  PhabricatorPolicyInterface  )----------------------------------------- */

  public function getCapabilities() {
    return array(
      PhabricatorPolicyCapability::CAN_VIEW,
      PhabricatorPolicyCapability::CAN_EDIT,
    );
  }

  public function getPolicy($capability) {

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Check import progress: bin/repository importing-status --id <repoID> and let the parse queue drain
  2. Requeue parsing for the commit: bin/repository reparse --message <monogram> --force
  3. Check worker/daemon logs for parse failures blocking the import (bin/worker list, daemon log)
  4. Verify the commit row was not manually created without an accompanying data record

Example fix

// before: called on a freshly discovered, unimported commit
$ref = $commit->newCommitRef($viewer);

// after: wait for or force the message parse first
if (!$commit->isImported()) {
  id(new PhabricatorRepositoryCommitParserWorker(
    array('commitPHID' => $commit->getPHID())))
    ->executeTask();
}
$ref = $commit->newCommitRef($viewer);
Defensive patterns

Strategy: validation

Validate before calling

// Only ask for the ref once the message parse has produced data.
if (!$commit->getCommitData() || !$commit->isImported()) {
  // requeue the parser instead of calling newCommitRef()
  id(new PhabricatorRepositoryCommitParserWorker(
    array('commitPHID' => $commit->getPHID())))
    ->executeTask();
}

Try / catch

try {
  $ref = $commit->newCommitRef($viewer);
} catch (Exception $ex) {
  // Commit discovered but not parsed yet: schedule the parse and retry later,
  // rather than surfacing the failure to the user.
  PhabricatorWorker::scheduleTask(
    'PhabricatorRepositoryCommitParserWorker',
    array('commitPHID' => $commit->getPHID()));
}

Prevention

When it happens

Trigger: Calling newCommitRef() on a commit whose import status is incomplete while the repository import is still running, or after the commit's parse task permanently failed; also on manually inserted commit rows that have no parsed data.

Common situations: Build adapters, audit handlers, or custom code that races the daemons on freshly discovered commits; large initial imports where discovery runs far ahead of parsing; parse workers stuck or erroring in the queue.

Related errors


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