{"record":{"id":"91f8a69d221928a9","repo":"phacility/phabricator","slug":"unable-to-retrieve-commitref-record-for-commit-s","errorCode":null,"errorMessage":"Unable to retrieve CommitRef record for commit \"%s\".","messagePattern":"Unable to retrieve CommitRef record for commit \"(.+?)\"\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/repository/storage/PhabricatorRepositoryCommit.php","lineNumber":573,"sourceCode":"        pht(\n          'Unable to retrieve details for commit \"%s\"!',\n          $commit_display));\n    }\n\n    if (count($result['data']) !== 1) {\n      throw new Exception(\n        pht(\n          'Got too many results (%s) for commit \"%s\", expected %s.',\n          phutil_count($result['data']),\n          $commit_display,\n          1));\n    }\n\n    $record = head($result['data']);\n    $ref_record = idxv($record, array('fields', 'ref'));\n\n    if (!$ref_record) {\n      throw new Exception(\n        pht(\n          'Unable to retrieve CommitRef record for commit \"%s\".',\n          $commit_display));\n    }\n\n    return DiffusionCommitRef::newFromDictionary($ref_record);\n  }\n\n/* -(  PhabricatorPolicyInterface  )----------------------------------------- */\n\n  public function getCapabilities() {\n    return array(\n      PhabricatorPolicyCapability::CAN_VIEW,\n      PhabricatorPolicyCapability::CAN_EDIT,\n    );\n  }\n\n  public function getPolicy($capability) {","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/storage/PhabricatorRepositoryCommit.php#L555-L591","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check import progress: bin/repository importing-status --id <repoID> and let the parse queue drain","Requeue parsing for the commit: bin/repository reparse --message <monogram> --force","Check worker/daemon logs for parse failures blocking the import (bin/worker list, daemon log)","Verify the commit row was not manually created without an accompanying data record"],"exampleFix":"// before: called on a freshly discovered, unimported commit\n$ref = $commit->newCommitRef($viewer);\n\n// after: wait for or force the message parse first\nif (!$commit->isImported()) {\n  id(new PhabricatorRepositoryCommitParserWorker(\n    array('commitPHID' => $commit->getPHID())))\n    ->executeTask();\n}\n$ref = $commit->newCommitRef($viewer);","handlingStrategy":"validation","validationCode":"// Only ask for the ref once the message parse has produced data.\nif (!$commit->getCommitData() || !$commit->isImported()) {\n  // requeue the parser instead of calling newCommitRef()\n  id(new PhabricatorRepositoryCommitParserWorker(\n    array('commitPHID' => $commit->getPHID())))\n    ->executeTask();\n}","typeGuard":null,"tryCatchPattern":"try {\n  $ref = $commit->newCommitRef($viewer);\n} catch (Exception $ex) {\n  // Commit discovered but not parsed yet: schedule the parse and retry later,\n  // rather than surfacing the failure to the user.\n  PhabricatorWorker::scheduleTask(\n    'PhabricatorRepositoryCommitParserWorker',\n    array('commitPHID' => $commit->getPHID()));\n}","preventionTips":["Never assume a discovered commit is parseable; check isImported()/getCommitData() first","Keep parse queues drained so discovery-to-parse lag stays short","Monitor permanent parse failures so stuck commits are noticed early"],"tags":["phabricator","diffusion","import","race-condition","commit-ref","php"],"backgroundTag":"incomplete-import-state","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}