phacility/phabricator · error · Exception
Unknown commit "%s"!
Error message
Unknown commit "%s"!
What it means
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.
Source
Thrown at src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php:135
WHERE commitIdentifier IN (%Ls) AND repositoryID = %d',
$commit_table_name,
$chunk,
$repo->getID());
foreach ($rows as $row) {
$map[$row['commitIdentifier']] = $row['id'];
}
}
$insert_sql = array();
$delete_sql = array();
foreach ($graph as $child => $parents) {
$names = $parents;
$names[] = $child;
foreach ($names as $name) {
if (empty($map[$name])) {
throw new Exception(pht('Unknown commit "%s"!', $name));
}
}
if (!$parents) {
// Write an explicit 0 to indicate "no parents" instead of "no data".
$insert_sql[] = qsprintf(
$conn_w,
'(%d, 0)',
$map[$child]);
} else {
foreach ($parents as $parent) {
$insert_sql[] = qsprintf(
$conn_w,
'(%d, %d)',
$map[$child],
$map[$parent]);
}
}View on GitHub (pinned to 5720a38cfe)
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.
Example fix
# before ./bin/repository parents R # Exception: Unknown commit "4f3a1c..."! # after: record every reachable commit first, then rebuild the parent cache ./bin/repository pull R ./bin/repository discover R ./bin/repository parents R
Defensive patterns
Strategy: validation
Validate before calling
# Finish discovery and confirm no pending import before rebuilding parent caches
./bin/repository pull R
./bin/repository discover R
php -r '
$repo = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIdentifiers(array("R"))
->executeOne();
if ($repo && $repo->isImporting()) {
fwrite(STDERR, "still importing; skip parents rebuild\n");
exit(1);
}'
./bin/repository parents R Try / catch
try {
// per repository, so one unreconciled repo does not abort the whole loop
$workflow->rebuildRepository($repo);
} catch (Exception $ex) {
// log identifier from the message, schedule discover+retry for this repo only
phlog($ex);
continue;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No commits have been discovered in the "%s" repository!
- Specify a method to call with "--method".
- Specify a file to read parameters from with "--input".
- No such user "%s" exists.
- No Conduit method provided.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/5f81d5b724181a10.
Report an issue: GitHub.