{"record":{"id":"bb224e733a2ae2c0","repo":"nikivdev/code","slug":"resolver-failed-for","errorCode":null,"errorMessage":"resolver {} failed for {}: {}","messagePattern":"resolver (.+?) failed for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":12585,"sourceCode":"        let command_text = render_reference_resolver_command(\n            &resolver.command,\n            candidate,\n            query_text,\n            target_path,\n        );\n        let args = shell_words::split(&command_text)\n            .with_context(|| format!(\"invalid resolver command: {}\", command_text))?;\n        let Some((program, rest)) = args.split_first() else {\n            bail!(\"empty resolver command for {}\", resolver.name);\n        };\n        let output = Command::new(program)\n            .args(rest)\n            .current_dir(target_path)\n            .output()\n            .with_context(|| format!(\"failed to run resolver {}\", resolver.name))?;\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();\n            bail!(\n                \"resolver {} failed for {}: {}\",\n                resolver.name,\n                candidate,\n                if stderr.is_empty() {\n                    format!(\"exit status {}\", output.status)\n                } else {\n                    stderr\n                }\n            );\n        }\n        let stdout = String::from_utf8_lossy(&output.stdout).trim().to_string();\n        if stdout.is_empty() {\n            bail!(\n                \"resolver {} returned empty output for {}\",\n                resolver.name,\n                candidate\n            );\n        }","sourceCodeStart":12567,"sourceCodeEnd":12603,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L12567-L12603","documentation":"After spawning a configured external resolver command, the tool checks the child's exit status. A non-zero exit bails with the resolver name, the candidate it ran against, and the resolver's stderr — or the exit status if stderr was empty. It surfaces external tool failures as a single diagnostic.","triggerScenarios":"The resolver program exits non-zero for a candidate: script bug, missing dependency inside the script, fzf canceled with Esc/Ctrl-C (exit 130), or the command requires a TTY/inputs it didn't get.","commonSituations":"fzf/interactive pickers aborted by the user; resolver scripts failing because HOME/cache/env differs; resolver not installed in PATH for the subprocess environment.","solutions":["Run the resolver command manually for that candidate to see the real failure","Install or fix the resolver program/dependencies it depends on","Make the resolver script tolerate no-selection (exit 0) or handle the failure case","Check PATH/env inside the spawned command's context"],"exampleFix":"// before (resolver script ends with)\nfzf  # aborting fzf exits non-zero\n// after\nsel=$(fzf) || exit 0\necho \"$sel\"","handlingStrategy":"try-catch","validationCode":"let status = Command::new(&program).args(&rest).current_dir(&target).status()?;\nif !status.success() {\n    eprintln!(\"resolver '{}' would fail ({}), skipping\", resolver.name, status);\n}","typeGuard":"fn resolver_runs(name: &str, program: &str, rest: &[String], dir: &Path) -> bool {\n    Command::new(program).args(rest).current_dir(dir).status().map(|s| s.success()).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"failed for\") => {\n        eprintln!(\"resolver failed; falling back to default selection\");\n        default_selection()\n    }\n    other => other,\n}","preventionTips":["Smoke-test resolver commands manually before wiring them in","Make resolver scripts exit 0 on user abort/no selection","Ensure resolver binaries are on PATH in every environment (CI included)"],"tags":["resolver","subprocess","external-command","exit-status"],"backgroundTag":"command-exited-nonzero","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}