{"record":{"id":"bac82469742a4569","repo":"LykosAI/StabilityMatrix","slug":"the-version-key-was-not-found-in-the-pip-show-output","errorCode":null,"errorMessage":"The 'Version' key was not found in the pip show output.","messagePattern":"The 'Version' key was not found in the pip show output\\.","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/PipShowResult.cs","lineNumber":74,"sourceCode":"            var value = split[1].Trim();\n\n            if (key == \"Name\" && linesDict.ContainsKey(\"Name\"))\n            {\n                // We've hit a new package, so stop parsing\n                break;\n            }\n\n            linesDict.TryAdd(key, value);\n        }\n\n        if (!linesDict.TryGetValue(\"Name\", out var name))\n        {\n            throw new FormatException(\"The 'Name' key was not found in the pip show output.\");\n        }\n\n        if (!linesDict.TryGetValue(\"Version\", out var version))\n        {\n            throw new FormatException(\"The 'Version' key was not found in the pip show output.\");\n        }\n\n        return new PipShowResult\n        {\n            Name = name,\n            Version = version,\n            Summary = linesDict.GetValueOrDefault(\"Summary\"),\n            HomePage = linesDict.GetValueOrDefault(\"Home-page\"),\n            Author = linesDict.GetValueOrDefault(\"Author\"),\n            AuthorEmail = linesDict.GetValueOrDefault(\"Author-email\"),\n            License = licenseText,\n            Location = linesDict.GetValueOrDefault(\"Location\"),\n            Requires = linesDict\n                .GetValueOrDefault(\"Requires\")\n                ?.Split(',', StringSplitOptions.TrimEntries)\n                .ToList(),\n            RequiredBy = linesDict\n                .GetValueOrDefault(\"Required-by\")","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/PipShowResult.cs#L56-L92","documentation":"PipShowResult.Parse requires a 'Version' key in the pip show output after finding 'Name'. If a Version line is missing while Name is present, the output is malformed or truncated, and a FormatException is thrown.","triggerScenarios":"Parsing pip show output whose lines stop after 'Name:' — truncated output, a modified/custom pip that omits Version, or hand-crafted metadata missing the Version line.","commonSituations":"Partially captured process output (buffer cut off), parsing pip variants (pip3, alternate distributors) with different output shapes, tests with incomplete fixture output.","solutions":["Ensure the full pip show stdout was captured (read all of StandardOutput before parsing)","Update/verify the pip version produces standard 'Name/Version/...' output","Fix the input fixture to include a 'Version:' line","Catch FormatException and treat the package metadata as invalid"],"exampleFix":"// before\n// truncated fixture: \"Name: numpy\\nHome-page: ...\"\n// after\n// fixture: \"Name: numpy\\nVersion: 1.26.0\\nHome-page: ...\"","handlingStrategy":"try-catch","validationCode":"if (!output.Contains(\"Version:\"))\n    throw new InvalidOperationException(\"pip show output truncated: Version line missing\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = PipShowResult.Parse(output);\n}\ncatch (FormatException ex)\n{\n    logger.LogWarning(ex, \"pip show output missing Version key\");\n    return null;\n}","preventionTips":["Read the process's full StandardOutput to the end before parsing","Keep pip updated so output shape stays standard","Use complete fixture output in tests"],"tags":["pip","parsing","format"],"backgroundTag":"unexpected-response-shape","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}