{"record":{"id":"dc3471466a9ca00e","repo":"JuliusBrussee/caveman","slug":"empty-version-output","errorCode":null,"errorMessage":"empty version output","messagePattern":"empty version output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/agent/src/cli.ts","lineNumber":431,"sourceCode":"function compareNodeVersion(current: string, minimum: string): number {\n  const parse = (value: string) => value.split(\".\").slice(0, 3).map((part) => Number(part));\n  const left = parse(current);\n  const right = parse(minimum);\n  for (let index = 0; index < 3; index++) {\n    const difference = (left[index] ?? 0) - (right[index] ?? 0);\n    if (difference !== 0) return difference;\n  }\n  return 0;\n}\n\nfunction safeDiagnostic(error: unknown): string {\n  const value = error instanceof Error ? error.message : String(error);\n  return value.replace(/[\\r\\n]+/g, \" \").slice(0, 512);\n}\n\nfunction runtimeVersionDiagnostic(stdout: string): string {\n  const value = stdout.trim();\n  if (value === \"\") throw new Error(\"empty version output\");\n  try {\n    const parsed = JSON.parse(value) as { version?: unknown; binary_release?: unknown };\n    if (typeof parsed.version === \"string\" && parsed.version.trim() !== \"\") {\n      const release = typeof parsed.binary_release === \"string\" && parsed.binary_release.trim() !== \"\"\n        ? ` (${parsed.binary_release.trim()})`\n        : \"\";\n      return `caveman ${parsed.version.trim()}${release}`;\n    }\n  } catch {\n    // Older CLIs may return one plain version line.\n  }\n  return value.replace(/[\\r\\n]+/g, \" \").slice(0, 256);\n}\n\nfunction credentialForModel(model: string): { name: string; available: boolean } {\n  const provider = model.split(\"/\", 1)[0];\n  if (provider === \"anthropic\") {\n    return { name: \"ANTHROPIC_API_KEY\", available: Boolean(process.env.ANTHROPIC_API_KEY) };","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/cli.ts#L413-L449","documentation":"runtimeVersionDiagnostic parses the trimmed stdout of a version probe (JSON containing version and optionally binary_release). If the output is empty after trimming, it throws \"empty version output\" because a version probe that printed nothing cannot yield a diagnostic string.","triggerScenarios":"The runtime CLI version command exits but writes nothing to stdout (crashed early, output redirected to stderr, or the binary is broken); doctor/version then calls runtimeVersionDiagnostic with \"\".","commonSituations":"A broken or partially installed runtime binary; a wrapper script swallowing stdout; an old runtime whose version output is on stderr instead of stdout.","solutions":["Run the runtime's version command manually and inspect both stdout and stderr to find why nothing printed.","Reinstall or repair the runtime CLI (e.g. re-run the engine/runtime install step).","Check the stderr-captured error message nearby in the version flow (safeDiagnostic) for the root cause.","Ensure the runtime binary on PATH is the correct one (not a stub or shim that suppresses output)."],"exampleFix":"// before (binary prints to stderr)\n$ runtime --version 2>/dev/null\n(nothing)\n// after: reinstall runtime so `runtime --version` prints JSON like {\"version\":\"1.2.3\"}","handlingStrategy":"try-catch","validationCode":"function assertNonEmptyStdout(stdout) {\n  if (typeof stdout !== \"string\" || stdout.trim() === \"\") {\n    throw new Error(\"runtime version probe produced no stdout; check the binary installation\");\n  }\n}","typeGuard":"function hasVersionPayload(v) { return typeof v === \"object\" && v !== null && typeof v.version === \"string\" && v.version.trim() !== \"\"; }","tryCatchPattern":"try {\n  const diag = runtimeVersionDiagnostic(stdout);\n} catch (e) {\n  if (e.message === \"empty version output\") {\n    console.error(\"Runtime CLI printed nothing on version probe; verify installation and run the command manually to see stderr\");\n  } else throw e;\n}","preventionTips":["Verify the runtime binary runs and prints JSON to stdout after install","Do not wrap the runtime in scripts that suppress stdout","Capture stderr alongside stdout when probing versions so failures are visible"],"tags":["version","diagnostics","empty-output","cli"],"backgroundTag":"empty-response-body","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}