{"record":{"id":"7ac7a3e926dc440c","repo":"phacility/phabricator","slug":"unexpected-number-of-output-lines-from-git-cat-fi","errorCode":null,"errorMessage":"Unexpected number of output lines from \"git cat-file\" when processing commit (\"%s\").","messagePattern":"Unexpected number of output lines from \"git cat-file\" when processing commit \\(\"(.+?)\"\\)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/diffusion/query/lowlevel/DiffusionLowLevelFilesizeQuery.php","lineNumber":115,"sourceCode":"\n    $future->write(implode(\"\\n\", array_keys($check_paths)));\n\n    $size_lines = id(new LinesOfALargeExecFuture($future))\n      ->setDelimiter(\"\\n\");\n    foreach ($size_lines as $line) {\n      $object_size = (int)$line;\n\n      $object_hash = head_key($check_paths);\n      $path_names = $check_paths[$object_hash];\n      unset($check_paths[$object_hash]);\n\n      foreach ($path_names as $path_name) {\n        $path_sizes[$path_name] = $object_size;\n      }\n    }\n\n    if ($check_paths) {\n      throw new Exception(\n        pht(\n          'Unexpected number of output lines from \"git cat-file\" when '.\n          'processing commit (\"%s\").',\n          $identifier));\n    }\n\n    return $path_sizes;\n  }\n\n}\n","sourceCodeStart":97,"sourceCodeEnd":126,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/query/lowlevel/DiffusionLowLevelFilesizeQuery.php#L97-L126","documentation":"DiffusionLowLevelFilesizeQuery computes the size of every file changed in a Git commit. It maps each changed path to its new blob hash via git diff-tree, then pipes the distinct hashes into 'git cat-file --batch-check=%(objectsize)' and consumes exactly one output line per hash. If cat-file returns fewer lines than hashes submitted, entries remain unconsumed in $check_paths and this exception is thrown for the commit identifier.","triggerScenarios":"Executing DiffusionLowLevelFilesizeQuery (used when rendering changed-file sizes for a commit page) on a commit whose blob objects are missing from the local clone, so cat-file emits no record for them; also when the object store is corrupted or being rewritten by a concurrent gc/repack.","commonSituations":"Corrupt or partially-pruned local clones after disk problems, interrupted clones, broken alternates, or a git gc racing the query. Typically one specific commit fails while neighbors render fine.","solutions":["Run 'git fsck' inside the repository's local path as the daemon user to locate missing or corrupt objects","Repair by deleting the local working copy and re-cloning: bin/repository update <callsign> (or trigger re-clone from Diffusion -> Manage)","Verify the daemon user can read every file under the local path; permission holes mimic corruption","Retry after any in-flight git gc finishes; if it persists, the commit's blobs are genuinely absent and only a re-clone fixes it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-verify the commit's blobs exist before the size query\n$future = $repository->getLocalCommandFuture('cat-file -e %s', $blob_hash);\nlist(, $err) = $future->resolve();\nif ($err) {\n  // object missing: skip size rendering for this commit\n}","typeGuard":null,"tryCatchPattern":"try {\n  $sizes = id(new DiffusionLowLevelFilesizeQuery())\n    ->setRepository($repository)\n    ->withIdentifier($commit_identifier)\n    ->executeQuery();\n} catch (Exception $ex) {\n  $sizes = array(); // sizes are cosmetic: degrade gracefully and log for triage\n  phlog($ex);\n}","preventionTips":["Treat file sizes as optional data so a corrupt object never breaks commit rendering","Run git fsck after any storage incident and re-clone damaged repositories","Keep daemon-side gc/prune from racing heavy browsing windows"],"tags":["git","diffusion","repository-corruption","cat-file"],"backgroundTag":"git-cat-file-output-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}