{"record":{"id":"cf8f97aca083f23a","repo":"nikivdev/code","slug":"codanna-mcp-get-index-info-failed","errorCode":null,"errorMessage":"'codanna mcp get_index_info' failed: {}","messagePattern":"'codanna mcp get_index_info' failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/indexer.rs","lineNumber":103,"sourceCode":"            \"'codanna index' exited with status {}\",\n            status.code().unwrap_or(-1)\n        );\n    }\n}\n\nfn capture_index_stats(binary: &Path, project_root: &Path) -> Result<String> {\n    println!(\"Fetching Codanna index metadata...\");\n    let output = Command::new(binary)\n        .arg(\"mcp\")\n        .arg(\"get_index_info\")\n        .arg(\"--json\")\n        .current_dir(project_root)\n        .output()\n        .with_context(|| \"failed to run 'codanna mcp get_index_info --json'\")?;\n\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\"'codanna mcp get_index_info' failed: {}\", stderr.trim());\n    }\n\n    let json: serde_json::Value = serde_json::from_slice(&output.stdout)\n        .with_context(|| \"failed to parse JSON from 'codanna mcp get_index_info --json'\")?;\n\n    serde_json::to_string_pretty(&json).with_context(|| \"failed to serialize Codanna stats payload\")\n}\n\nfn persist_snapshot(\n    project_root: &Path,\n    binary: &Path,\n    payload: &str,\n    override_path: Option<PathBuf>,\n) -> Result<PathBuf> {\n    let db_path = override_path.unwrap_or_else(default_db_path);\n    if let Some(parent) = db_path.parent() {\n        fs::create_dir_all(parent)\n            .with_context(|| format!(\"failed to create directory {}\", parent.display()))?;","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/indexer.rs#L85-L121","documentation":"capture_index_stats runs `codanna mcp get_index_info --json` and captures its output. If the command exits non-zero, its trimmed stderr is embedded in this bail! error. The stderr content after the colon is codanna's own diagnostic, so this error is a wrapper around whatever codanna reported.","triggerScenarios":"Running the indexer's stats capture step when `codanna mcp get_index_info --json` fails: unknown subcommand in old codanna versions, uninitialized index, or codanna runtime error.","commonSituations":"Installed codanna version predates the `mcp get_index_info` subcommand; index missing because `codanna index` never ran or failed; codanna crashes while reading index metadata.","solutions":["Read the stderr text in the error message — it contains codanna's actual diagnostic.","Verify your codanna version supports `codanna mcp get_index_info --json` by running it manually; upgrade if the subcommand is unknown.","Ensure `codanna init` and `codanna index` succeeded before capturing stats.","Run the command in the project root manually to reproduce and debug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the subcommand exists on this codanna version\nlet probe = std::process::Command::new(\"codanna\")\n    .args([\"mcp\", \"get_index_info\", \"--json\"])\n    .output()?;\nif !probe.status.success() {\n    eprintln!(\"get_index_info unsupported/failing: {}\",\n        String::from_utf8_lossy(&probe.stderr));\n}","typeGuard":null,"tryCatchPattern":"match run_indexer() {\n    Ok(stats) => handle(stats),\n    Err(e) if e.to_string().contains(\"get_index_info' failed\") => {\n        // stderr after the colon is codanna's own diagnostic\n        eprintln!(\"stats capture failed: {e}; check codanna version supports mcp get_index_info\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Pin/upgrade codanna to a version that supports `mcp get_index_info --json`","Complete init and index steps before capturing stats","Surface the embedded stderr (text after the colon) when triaging"],"tags":["subprocess","external-tool","exit-code","json"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}