{"record":{"id":"786c581bedf1d2d8","repo":"phacility/phabricator","slug":"failed-to-parse-s-output-s","errorCode":null,"errorMessage":"Failed to parse `%s` output: %s","messagePattern":"Failed to parse `(.+?)` output: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php","lineNumber":154,"sourceCode":"    $future->write(implode(\"\\n\", $unresolved));\n    list($stdout) = $future->resolvex();\n\n    $lines = explode(\"\\n\", rtrim($stdout, \"\\n\"));\n    if (count($lines) !== count($unresolved)) {\n      throw new Exception(\n        pht(\n          'Unexpected line count from `%s`!',\n          'git cat-file'));\n    }\n\n    $hits = array();\n    $tags = array();\n\n    $lines = array_combine($unresolved, $lines);\n    foreach ($lines as $ref => $line) {\n      $parts = explode(' ', $line);\n      if (count($parts) < 2) {\n        throw new Exception(\n          pht(\n            'Failed to parse `%s` output: %s',\n            'git cat-file',\n            $line));\n      }\n      list($identifier, $type) = $parts;\n\n      if ($type == 'missing') {\n        // This is either an ambiguous reference which resolves to several\n        // objects, or an invalid reference. For now, always treat it as\n        // invalid. It would be nice to resolve all possibilities for\n        // ambiguous references at some point, although the strategy for doing\n        // so isn't clear to me.\n        continue;\n      }\n\n      switch ($type) {\n        case 'commit':","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php#L136-L172","documentation":"Each output line of 'git cat-file --batch-check' is expected to contain at least two space-separated fields: the object identifier and its type (plus optional size). A line with fewer than two fields cannot be interpreted, so the query throws and includes the raw offending line in the message.","triggerScenarios":"An empty or single-token line in the batch output: usually a trailing blank line after a newline-containing ref desynchronized the stream, or git wrote an error or blank line where a batch record was expected.","commonSituations":"Same family as the line-count mismatch: refs with embedded newlines, git error text interleaved with batch output, or a repository/objects in a bad state.","solutions":["Sanitize refs (no newline characters) before resolving them","Run the same batch-check command manually with the same refs to inspect raw output","Check git version consistency across web/daemon hosts in the cluster","If output looks truncated, check disk space and repository health (git fsck)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  $resolved = $query->execute();\n} catch (Exception $ex) {\n  // Batch stream unparseable: treat all submitted refs as invalid\n  $resolved = array();\n  phlog($ex);\n}","preventionTips":["Sanitize refs before resolution (same guard as the line-count mismatch)","Keep git versions uniform across web and daemon hosts","Watch for interleaved git error output when disk space is low"],"tags":["git","parsing","ref-resolution"],"backgroundTag":"git-cat-file-output-mismatch","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}