{"record":{"id":"afd94df6a23e1342","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-config-file-file-contents-were","errorCode":null,"errorMessage":"Failed to parse config file {}; file contents were omitted","messagePattern":"Failed to parse config file (.+?); file contents were omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":11543,"sourceCode":"            ),\n            modelstudio_coding_plan: merge_provider_config(\n                base.modelstudio_coding_plan,\n                override_cfg.modelstudio_coding_plan,\n            ),\n            modelstudio_coding_plan_anthropic: merge_provider_config(\n                base.modelstudio_coding_plan_anthropic,\n                override_cfg.modelstudio_coding_plan_anthropic,\n            ),\n            custom: merge_custom_providers(base.custom, override_cfg.custom),\n        }),\n    }\n}\n\nfn load_single_config_file(path: &Path) -> Result<Config> {\n    let contents = fs::read_to_string(path)\n        .with_context(|| format!(\"Failed to read config file: {}\", path.display()))?;\n    let parsed: ConfigFile = toml::from_str(&contents).map_err(|_| {\n        anyhow::anyhow!(\n            \"Failed to parse config file {}; file contents were omitted\",\n            codewhale_config::quote_os_path(path)\n        )\n    })?;\n    Ok(*parsed.base)\n}\n\n/// Build a one-line warning when top-level-only keys are nested under a section\n/// Codewhale does not define (`[general]` / `[sandbox]`). TOML silently drops\n/// those keys, so e.g. `[general]\\nallow_shell = true` never takes effect and\n/// the shell tools (`exec_shell`, `task_shell_start`, …) are absent from the\n/// catalog with no explanation. Returns `None` when nothing is misplaced.\n///\n/// This is the exact confusion behind #2589: `allow_shell` and `sandbox_mode`\n/// belong at the top of the file, above any `[section]` header.\nfn warn_on_misplaced_top_level_keys(raw: &str) -> Option<String> {\n    let doc = toml::from_str::<toml::Value>(raw).ok()?;\n    // Sections Codewhale does not recognize but users nest settings under.","sourceCodeStart":11525,"sourceCodeEnd":11561,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L11525-L11561","documentation":"Thrown by `load_single_config_file` when a config file reads fine but `toml::from_str::<ConfigFile>` cannot parse it. The path is quoted via `quote_os_path` and, per the codebase-wide convention, the file contents and offending keys are omitted from the message because configs may contain secrets.","triggerScenarios":"Calling `load_single_config_file(path)` on a config file whose TOML syntax or schema is invalid; the distinct 'Failed to read config file' error covers unreadable files, this one covers unparseable content.","commonSituations":"A merge conflict marker (`<<<<<<<`) left in config.toml; trailing text after a table; a key duplicated within the same table after hand-merging settings; editing on Windows and pasting a smart quote.","solutions":["Run the file through a TOML linter/validator and fix the reported syntax error","Search the file for merge-conflict markers and stray characters, then remove them","Restore the file from version control or back it up and let the app regenerate defaults"],"exampleFix":"// before\n<<<<<<< HEAD\nmodel = \"a\"\n=======\nmodel = \"b\"\n>>>>>>> main\n// after\nmodel = \"b\"","handlingStrategy":"try-catch","validationCode":"let contents = std::fs::read_to_string(&path)?;\ncontents.parse::<toml::Value>().map_err(|e| anyhow!(\"config file {} TOML invalid: {e}\", path.display()))?;","typeGuard":null,"tryCatchPattern":"match load_single_config_file(&path) {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"Failed to parse config file\") => {\n        eprintln!(\"Check TOML syntax in {} (contents omitted from the error)\", path.display());\n        Config::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve merge conflicts in config files completely — search for conflict markers before launching","Run a TOML formatter/linter on config files in CI","Avoid editing configs with editors that insert smart quotes"],"tags":["config","toml","parse-error","file"],"backgroundTag":"toml-parse-error","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"}