LykosAI/StabilityMatrix · error · FormatException
The 'Version' key was not found in the pip show output.
Error message
The 'Version' key was not found in the pip show output.
What it means
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.
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
Example fix
// before // truncated fixture: "Name: numpy\nHome-page: ..." // after // fixture: "Name: numpy\nVersion: 1.26.0\nHome-page: ..."
Defensive patterns
Strategy: try-catch
Validate before calling
if (!output.Contains("Version:"))
throw new InvalidOperationException("pip show output truncated: Version line missing"); Try / catch
try
{
var result = PipShowResult.Parse(output);
}
catch (FormatException ex)
{
logger.LogWarning(ex, "pip show output missing Version key");
return null;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Partially captured process output (buffer cut off), parsing pip variants (pip3, alternate distributors) with different output shapes, tests with incomplete fixture output.
Related errors
- The 'Name' key was not found in the pip show output.
- Expected opening brace.
- Fields line not found
- get-pip not found
- Install script failed with exit code
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/bac82469742a4569.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/PipShowResult.cs:74
var value = split[1].Trim();
if (key == "Name" && linesDict.ContainsKey("Name"))
{
// We've hit a new package, so stop parsing
break;
}
linesDict.TryAdd(key, value);
}
if (!linesDict.TryGetValue("Name", out var name))
{
throw new FormatException("The 'Name' key was not found in the pip show output.");
}
if (!linesDict.TryGetValue("Version", out var version))
{
throw new FormatException("The 'Version' key was not found in the pip show output.");
}
return new PipShowResult
{
Name = name,
Version = version,
Summary = linesDict.GetValueOrDefault("Summary"),
HomePage = linesDict.GetValueOrDefault("Home-page"),
Author = linesDict.GetValueOrDefault("Author"),
AuthorEmail = linesDict.GetValueOrDefault("Author-email"),
License = licenseText,
Location = linesDict.GetValueOrDefault("Location"),
Requires = linesDict
.GetValueOrDefault("Requires")
?.Split(',', StringSplitOptions.TrimEntries)
.ToList(),
RequiredBy = linesDict
.GetValueOrDefault("Required-by")View on GitHub (pinned to af93d6ef57)