{"record":{"id":"09e4a79cdb3b6f18","repo":"Hmbown/CodeWhale","slug":"doctor-configuration-validation-failed-see-json-o","errorCode":null,"errorMessage":"doctor configuration validation failed; see JSON output","messagePattern":"doctor configuration validation failed; see JSON output","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":6993,"sourceCode":"/// Emit a bounded, secret-redacted JSON failure when configuration cannot be\n/// loaded or validated. Invalid configuration must not be forced through the\n/// normal doctor report because its route/capability facts would be misleading.\nfn run_doctor_json_config_error(error: &anyhow::Error) -> Result<()> {\n    let safe_message = error\n        .downcast_ref::<crate::config::SafeConfigDiagnostic>()\n        .map(ToString::to_string);\n    let report = serde_json::json!({\n        \"status\": \"error\",\n        \"error\": {\n            \"kind\": \"config_validation\",\n            \"message\": safe_message.as_deref().unwrap_or(\"configuration validation failed; details omitted because configuration errors may contain credential material\"),\n        },\n    });\n    println!(\"{}\", serde_json::to_string_pretty(&report)?);\n\n    // Keep stderr generic: the actionable, redacted error is already on\n    // stdout, and Rust's Result termination must never redisclose a secret.\n    bail!(\"doctor configuration validation failed; see JSON output\")\n}\n\n/// Machine-readable counterpart to `run_doctor`. This report is always\n/// structural and offline; live probe flags conflict with `--json`.\nfn run_doctor_json(\n    config: &Config,\n    workspace: &Path,\n    config_path_override: Option<&Path>,\n    plugins: &crate::plugins::PluginRegistry,\n) -> Result<()> {\n    use serde_json::json;\n\n    let doctor_paths = crate::doctor::DoctorPathReport::resolve(config_path_override)?;\n    let config_path = &doctor_paths.config;\n    let secret_backend = codewhale_secrets::diagnose_secret_backend();\n\n    let credential = resolve_credential_diagnostic(config);\n","sourceCodeStart":6975,"sourceCodeEnd":7011,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L6975-L7011","documentation":"The `doctor` command validates the configuration and prints a redacted, actionable JSON report on stdout; if validation failed it then bails with this generic message so the process exits non-zero. The generic message is deliberate: the Rust Result termination must never re-print (and risk redisclosing) a secret, so all specifics stay in the redacted JSON.","triggerScenarios":"Running `codewhale doctor` when run_doctor's validation produced errors in the report (bad provider settings, missing/invalid keys, malformed config values).","commonSituations":"After editing a config file with a typo or an invalid provider/model value; rotating API keys and leaving one empty or malformed; copying a config from another machine with environment-specific values.","solutions":["Read the JSON report doctor printed to stdout — it contains the redacted, actionable validation errors","Fix each reported config field and rerun `doctor` until validation passes","Validate the config file syntax (JSON/TOML) and required provider fields","Restore secrets/keys that were left empty during rotation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let report = validate_config(&config);\nfor issue in &report.issues {\n    eprintln!(\"config issue: {issue}\");\n}\nif !report.valid { std::process::exit(1); }","typeGuard":null,"tryCatchPattern":"// parse the doctor JSON stdout instead of relying on the generic stderr message\nlet report: DoctorReport = serde_json::from_str(&doctor_stdout)?;\nfor issue in report.validation_issues { /* act on redacted detail */ }","preventionTips":["Run `doctor` after every config edit and read its JSON output","Never rely on the stderr message for details — the JSON report is authoritative and redacted","Keep secrets out of logged config validation output"],"tags":["cli","config","validation","doctor"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}