{"record":{"id":"febf74b08afe51dd","repo":"phacility/phabricator","slug":"cache-returned-bogus-result","errorCode":null,"errorMessage":"Cache returned bogus result!","messagePattern":"Cache returned bogus result!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/repository/management/PhabricatorRepositoryManagementCacheWorkflow.php","lineNumber":80,"sourceCode":"    $console = PhutilConsole::getConsole();\n\n    $console->writeOut(\n      \"%s\\n\",\n      pht('Query took %s ms.', new PhutilNumber(1000 * ($t_end - $t_start))));\n\n    if ($cache_result === false) {\n      $console->writeOut(\"%s\\n\", pht('Not found in graph cache.'));\n    } else if ($cache_result === null) {\n      $console->writeOut(\n        \"%s\\n\",\n        pht('Path not modified in any ancestor commit.'));\n    } else {\n      $last = id(new DiffusionCommitQuery())\n        ->setViewer($this->getViewer())\n        ->withIDs(array($cache_result))\n        ->executeOne();\n      if (!$last) {\n        throw new Exception(pht('Cache returned bogus result!'));\n      }\n\n      $console->writeOut(\n        \"%s\\n\",\n        pht(\n          'Path was last changed at %s.',\n          $commit->getRepository()->formatCommitName(\n            $last->getcommitIdentifier())));\n    }\n\n    return 0;\n  }\n\n}\n","sourceCodeStart":62,"sourceCodeEnd":95,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/repository/management/PhabricatorRepositoryManagementCacheWorkflow.php#L62-L95","documentation":"Thrown by the 'bin/repository cache' workflow: the graph cache (PhabricatorRepositoryGraphCache) returned a cached last-modified commit ID, but DiffusionCommitQuery could not load a commit row with that ID. The cache holds a fast path over the authoritative commit table, so this means the cache contains a stale or bogus entry pointing at a commit that no longer exists, typically after history rewriting, repository re-creation, or partial data loss.","triggerScenarios":"Repository history rewritten (force-push or rebase) invalidating cached commit IDs; repository deleted and re-imported while the graph cache backend (Redis or files) kept old entries; commit rows removed by a repair script; cache key collision or corruption.","commonSituations":"Heavy history rewriting on Git repositories; restoring a Phabricator DB dump without flushing the matching cache backend; mixed cache state after switching cache configuration.","solutions":["Clear the repository graph cache so entries repopulate from the authoritative tables (flush the cache backend or use the repository cache-clearing maintenance), then re-run the command","If commits were genuinely deleted by a history rewrite, verify commit table state and expect re-import work","Verify cache backend health (Redis reachable, cache directory writable) if bogus values appear broadly"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Distrust cache hits that reference nonexistent commits:\n$commit = id(new DiffusionCommitQuery())\n  ->setViewer($viewer)\n  ->withIDs(array($cached_id))\n  ->executeOne();\nif (!$commit) {\n  // treat the cache entry as bogus: bypass or flush and recompute from source data\n}","typeGuard":null,"tryCatchPattern":"try {\n  $cached = $graph_cache->loadLastModifiedCommitID($commit_id, $path_id);\n} catch (Exception $ex) {\n  if (preg_match('/bogus result/', $ex->getMessage())) {\n    // fall back to uncached computation after flushing the graph cache\n  }\n}","preventionTips":["Flush graph caches whenever repository history is rewritten or repos are re-imported","Keep cache backends and DB restores consistent: flush cache after a DB rollback","Monitor for bogus-result errors as a canary for cache and DB divergence"],"tags":["phabricator","cache","stale-cache","repository-graph"],"backgroundTag":"stale-cache-entry","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}