{"record":{"id":"e847fe76e4f0c6f9","repo":"xai-org/grok-build","slug":"cannot-apply-this-fix-without-confirmation-run-it","errorCode":null,"errorMessage":"Cannot apply this fix without confirmation. Run it in an interactive terminal or add `--yes`.","messagePattern":"Cannot apply this fix without confirmation\\. Run it in an interactive terminal or add `--yes`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/doctor_cmd/mod.rs","lineNumber":148,"sourceCode":"    );\n    let request = crate::diagnostics::FixRequest::from_environment(id)?;\n    let plan = crate::diagnostics::plan_fix(request, &report, &terminal)?;\n    apply_fix_plan(args, stdin_is_terminal, input, writer, &terminal, plan)\n}\n\nfn apply_fix_plan(\n    args: FixArgs,\n    stdin_is_terminal: bool,\n    input: &mut impl std::io::BufRead,\n    writer: &mut impl Write,\n    terminal: &crate::terminal::TerminalContext,\n    plan: FixPlan,\n) -> Result<()> {\n    write_fix_preview(&plan, writer)?;\n\n    if !args.yes {\n        if !stdin_is_terminal {\n            anyhow::bail!(\n                \"Cannot apply this fix without confirmation. Run it in an interactive terminal or add `--yes`.\"\n            );\n        }\n        write!(writer, \"\\nApply this fix? [y/N] \")?;\n        writer.flush()?;\n        let mut answer = String::new();\n        input.read_line(&mut answer)?;\n        if !matches!(answer.trim().to_ascii_lowercase().as_str(), \"y\" | \"yes\") {\n            writeln!(writer, \"Fix cancelled.\")?;\n            return Ok(());\n        }\n    }\n\n    let outcome = crate::diagnostics::apply_fix(plan)?;\n    if outcome.activation() == FixActivation::SatisfiedNow {\n        // Use the shell stored on the outcome (from planning), not `$SHELL`.\n        // `$SHELL` may be missing or no longer match the shell the plan targeted.\n        let post_report = crate::diagnostics::configured_report(","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/doctor_cmd/mod.rs#L130-L166","documentation":"`apply_fix_plan` previews the fix, then requires confirmation. When `--yes` was not passed and stdin is not a terminal, it cannot safely prompt, so it bails before making any change rather than applying a fix without explicit consent.","triggerScenarios":"Running a `doctor` fix with `args.yes == false` while `stdin_is_terminal == false` — e.g. piping input, running under CI, or invoking through a non-TTY wrapper. Reached from `run_fix` and covered by `non_tty_without_yes_fails_safely_before_write` and `decline_is_success_and_does_not_write`.","commonSituations":"Automating doctor fixes in CI without `--yes`; piping the command (`echo | grok doctor fix ...`); running inside a daemon/script executor with no TTY.","solutions":["Add `--yes` to the doctor fix command to confirm non-interactively.","Run the command in an interactive terminal so the [y/N] prompt can be answered.","In CI, explicitly opt in: `grok doctor <fix> --yes` after reviewing the preview."],"exampleFix":"// before\ngrok doctor fix-config < /dev/null\n// after\ngrok doctor fix-config --yes","handlingStrategy":"validation","validationCode":"let interactive = std::io::stdin().is_terminal();\nif !interactive && !args.yes {\n    eprintln!(\"Non-interactive run: add --yes to confirm the doctor fix.\");\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = doctor_fix(args) {\n    if e.to_string().contains(\"without confirmation\") {\n        eprintln!(\"Re-run with --yes (after reviewing the preview) or in a TTY.\");\n    } else { return Err(e); }\n}","preventionTips":["Pass --yes explicitly in CI after reviewing what the fix changes","Check `stdin.is_terminal()` before invoking fix commands from scripts","Avoid piping stdin into doctor fix commands"],"tags":["doctor","confirmation","non-interactive","cli"],"backgroundTag":"confirmation-required-non-interactive","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}