{"record":{"id":"54771edee6c6dd5f","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-config-at-file-contents-were-o-54771e","errorCode":null,"errorMessage":"failed to parse config at {}; file contents were omitted","messagePattern":"failed to parse config at (.+?); file contents were omitted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/commands/groups/utility/network.rs","lineNumber":189,"sourceCode":"    crate::config_persistence::mutate_config_document(&path, |doc| {\n        ensure_network_defaults(doc)?;\n        crate::config_persistence::set_document_value(doc, &[\"network\", \"default\"], normalized)\n    })?;\n\n    Ok(format!(\n        \"Network default set to {normalized}\\nSaved to {}.\",\n        path.display()\n    ))\n}\n\nfn load_config_doc(path: &Path) -> anyhow::Result<Value> {\n    if !path.exists() {\n        return Ok(Value::Table(toml::value::Table::new()));\n    }\n    let raw = fs::read_to_string(path)\n        .with_context(|| format!(\"failed to read config at {}\", path.display()))?;\n    toml::from_str(&raw).map_err(|_| {\n        anyhow::anyhow!(\n            \"failed to parse config at {}; file contents were omitted\",\n            codewhale_config::quote_os_path(path)\n        )\n    })\n}\n\nfn ensure_network_defaults(doc: &mut toml_edit::DocumentMut) -> anyhow::Result<()> {\n    if doc\n        .get(\"network\")\n        .and_then(toml_edit::Item::as_table_like)\n        .and_then(|table| table.get(\"default\"))\n        .is_none()\n    {\n        crate::config_persistence::set_document_value(doc, &[\"network\", \"default\"], \"prompt\")?;\n    }\n    if doc\n        .get(\"network\")\n        .and_then(toml_edit::Item::as_table_like)","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/commands/groups/utility/network.rs#L171-L207","documentation":"The /network command loads the TOML config via load_config_doc before editing it. If the file exists but toml::from_str fails, it errors with 'failed to parse config at <path>'; file contents are deliberately omitted (crates/tui/src/commands/groups/utility/network.rs:189) because the config may contain secrets.","triggerScenarios":"A hand-edited config with an unclosed string, duplicate key, or missing bracket; a bad merge-conflict resolution; a BOM or smart quotes inserted by an editor; a file truncated by a crash during save.","commonSituations":"Editing config.toml in a new editor that auto-inserts smart quotes or CRLF; git merge artifacts; multi-tool setups where another tool rewrote the file.","solutions":["Validate the file: python3 -c \"import tomllib,sys; tomllib.load(open(sys.argv[1],'rb'))\" <path>","Fix duplicate keys, unclosed quotes/brackets, and smart-quote characters around recent edits","Restore the file from backup or git history and reapply only the intended change","Retry the /network command once the file parses"],"exampleFix":"# config.toml - before\n[network]\ndefault = \"kimi   # unclosed string, parse fails\n\n# config.toml - after\n[network]\ndefault = \"kimi\"\n","handlingStrategy":"validation","validationCode":"# Before running /network, prove the file parses\npython3 -c \"import tomllib,sys; tomllib.load(open(sys.argv[1],'rb'))\" ~/.codewhale/config.toml && echo OK","typeGuard":null,"tryCatchPattern":"// In Rust: parse-or-refuse before editing\nlet doc: toml::Value = toml::from_str(&raw)\n    .map_err(|e| anyhow::anyhow!(\"config unparseable, refusing edit: {e}\"))?;","preventionTips":["Lint config.toml in CI or a pre-commit hook","Keep one logical edit per config change","Avoid editors that inject smart quotes or BOMs into TOML"],"tags":["config","toml","cli","network"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}