{"record":{"id":"3efefda61868d07f","repo":"nikivdev/code","slug":"exited-with","errorCode":null,"errorMessage":"{} exited with {}","messagePattern":"(.+?) exited with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/base_tool.rs","lineNumber":33,"sourceCode":"    for name in [\"base\", \"db\"] {\n        if let Ok(path) = which::which(name) {\n            return Some(path);\n        }\n    }\n\n    None\n}\n\npub fn run_inherit_stdio(bin: &Path, args: &[String]) -> Result<()> {\n    let status = Command::new(bin)\n        .args(args)\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .with_context(|| format!(\"failed to run {} {}\", bin.display(), args.join(\" \")))?;\n    if !status.success() {\n        anyhow::bail!(\"{} exited with {}\", bin.display(), status);\n    }\n    Ok(())\n}\n\npub fn run_with_stdin(bin: &Path, args: &[String], stdin: &str) -> Result<()> {\n    let mut child = Command::new(bin)\n        .args(args)\n        .stdin(Stdio::piped())\n        .stdout(Stdio::null())\n        // This path is currently only used for best-effort \"task run\" ingestion.\n        // If the user has some other `base` binary on PATH (or an older one),\n        // it may print usage/errors like \"unrecognized subcommand 'ingest'\".\n        // We intentionally silence stderr to avoid confusing noise during normal runs.\n        .stderr(Stdio::null())\n        .spawn()\n        .with_context(|| format!(\"failed to spawn {} {}\", bin.display(), args.join(\" \")))?;\n\n    {","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/base_tool.rs#L15-L51","documentation":"`run_inherit_stdio` (src/base_tool.rs:33) spawns an external binary with inherited stdio and checks the exit `status`. If the child process terminates with a non-zero exit code (or a signal), it bails with \"<binary> exited with <status>\". This surfaces underlying tool failures (linters, formatters, etc.) as an anyhow error.","triggerScenarios":"Any call to `run_inherit_stdio(bin, args)` where the spawned process returns a non-success exit code or is killed by a signal — e.g. the tool itself fails validation, file not found by the tool, or user Ctrl+C.","commonSituations":"The wrapped CLI tool (linter/compiler) fails on the user's code; tool misconfigured via args; tool killed by SIGKILL/OOM; sandbox denies execution inputs.","solutions":["Read the child tool's own stderr/stdout output (inherited, so it's already printed) for the real cause","Re-run the failing binary directly with the same arguments to reproduce","Fix the input/config that makes the underlying tool fail","In caller code, decide whether non-zero exit should be tolerated instead of propagated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the binary exists and is executable before invoking\nif !bin.exists() {\n    anyhow::bail!(\"tool not found: {}\", bin.display());\n}","typeGuard":"fn is_success(status: &std::process::ExitStatus) -> bool { status.success() }","tryCatchPattern":"match run_inherit_stdio(&bin, &args) {\n    Err(e) if e.to_string().contains(\"exited with\") => {\n        eprintln!(\"wrapped tool failed; see its output above for the cause\");\n        // optionally tolerate specific exit codes here\n    }\n    other => other?,\n}","preventionTips":["Always read the wrapped tool's stdout/stderr — it's inherited and printed","Validate tool arguments/config before spawning","Decide explicitly which exit codes are acceptable in your pipeline"],"tags":["process","exit-code","subprocess"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}