{"record":{"id":"5f81d5b724181a10","repo":"phacility/phabricator","slug":"unknown-commit-s","errorCode":null,"errorMessage":"Unknown commit \"%s\"!","messagePattern":"Unknown commit \"(.+?)\"!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php","lineNumber":135,"sourceCode":"          WHERE commitIdentifier IN (%Ls) AND repositoryID = %d',\n        $commit_table_name,\n        $chunk,\n        $repo->getID());\n      foreach ($rows as $row) {\n        $map[$row['commitIdentifier']] = $row['id'];\n      }\n    }\n\n    $insert_sql = array();\n    $delete_sql = array();\n\n    foreach ($graph as $child => $parents) {\n      $names = $parents;\n      $names[] = $child;\n\n      foreach ($names as $name) {\n        if (empty($map[$name])) {\n          throw new Exception(pht('Unknown commit \"%s\"!', $name));\n        }\n      }\n\n      if (!$parents) {\n        // Write an explicit 0 to indicate \"no parents\" instead of \"no data\".\n        $insert_sql[] = qsprintf(\n          $conn_w,\n          '(%d, 0)',\n          $map[$child]);\n      } else {\n        foreach ($parents as $parent) {\n          $insert_sql[] = qsprintf(\n            $conn_w,\n            '(%d, %d)',\n            $map[$child],\n            $map[$parent]);\n        }\n      }","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php#L117-L153","documentation":"Thrown by the `bin/repository parents` cache-rebuild workflow. It walks the full commit graph of every tracked branch in a repository (PhabricatorGitGraphStream / PhabricatorMercurialGraphStream), then bulk-loads rows from the repository_commit table into $map (commitIdentifier => id). Every identifier the walk touched, each child and each of its parents, must appear in $map; a reachable commit with no database row for this repository aborts the rebuild with this plain Exception.","triggerScenarios":"Running `./bin/repository parents <repository>` when the on-disk working copy contains commits reachable from tracked branch heads that discovery never recorded: discovery was interrupted or has not run since the last push/pull, ref cursors are stale so the graph stream walks past commits lacking repository_commit rows, or the local clone was replaced with one carrying extra history.","commonSituations":"Rebuilding parent caches right after cloning or restoring a repository before the daemons finish discovery; racing an active import; a database restored from backup while the working copy on disk is newer or older than the backup; Mercurial/Git identifier formatting differences between the stream and stored rows.","solutions":["Run discovery first so every reachable commit gets a repository_commit row, then rebuild: `./bin/repository discover R && ./bin/repository parents R` (add `./bin/repository pull R` first if the local copy is stale).","If the repository is still importing, wait for discovery/parsing to finish (check `./bin/phd status` and the import state in Diffusion) before rebuilding caches.","Verify the failing identifier in the database: `SELECT * FROM repository_commit WHERE commitIdentifier = '<hash>' AND repositoryID = <id>;` — a missing row confirms incomplete discovery, not a workflow bug.","Check tracked-branch configuration (`repository.branch-pattern`, `shouldTrackBranch`) so the walk does not descend into refs Phabricator never imported.","If the database and working copy genuinely disagree (restored backup, migrated host), reclone or reimport the repository so disk state matches Phabricator's records."],"exampleFix":"# before\n./bin/repository parents R\n# Exception: Unknown commit \"4f3a1c...\"!\n\n# after: record every reachable commit first, then rebuild the parent cache\n./bin/repository pull R\n./bin/repository discover R\n./bin/repository parents R","handlingStrategy":"validation","validationCode":"# Finish discovery and confirm no pending import before rebuilding parent caches\n./bin/repository pull R\n./bin/repository discover R\nphp -r '\n  $repo = id(new PhabricatorRepositoryQuery())\n    ->setViewer(PhabricatorUser::getOmnipotentUser())\n    ->withIdentifiers(array(\"R\"))\n    ->executeOne();\n  if ($repo && $repo->isImporting()) {\n    fwrite(STDERR, \"still importing; skip parents rebuild\\n\");\n    exit(1);\n  }'\n./bin/repository parents R","typeGuard":null,"tryCatchPattern":"try {\n  // per repository, so one unreconciled repo does not abort the whole loop\n  $workflow->rebuildRepository($repo);\n} catch (Exception $ex) {\n  // log identifier from the message, schedule discover+retry for this repo only\n  phlog($ex);\n  continue;\n}","preventionTips":["Always run `discover` (and `pull` where applicable) to completion before `bin/repository parents`.","Never rebuild caches while the repository is still importing; check `isImporting()` or `./bin/phd status` first.","When restoring environments, keep the database backup and the on-disk working copies from the same point in time."],"tags":["php","phabricator","cli","git","mercurial","repository-import","parent-cache"],"backgroundTag":"commit-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}