{"record":{"id":"6a206fc0df5cf14d","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-configuration-file-contents-were-omitted","errorCode":null,"errorMessage":"Failed to parse configuration; file contents were omitted","messagePattern":"Failed to parse configuration; file contents were omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":4853,"sourceCode":"    /// Load configuration for a structural diagnostic without materializing\n    /// secret-bearing environment values into the returned configuration.\n    ///\n    /// This still applies the ordinary safe routing, model, and policy\n    /// overrides so doctor describes the runtime the user selected. Provider\n    /// credentials are resolved only inside an explicit live-probe boundary.\n    pub(crate) fn load_structural(path: Option<PathBuf>, profile: Option<&str>) -> Result<Self> {\n        Self::load_with_environment_policy(\n            path,\n            profile,\n            ConfigEnvironmentPolicy::StructuralDiagnostic,\n        )\n    }\n\n    /// Parse persisted configuration through the same profile precedence used\n    /// at startup, without environment, credentials, or filesystem writes.\n    pub(crate) fn from_saved_document(contents: &str, profile: Option<&str>) -> Result<Self> {\n        let parsed: ConfigFile = toml::from_str(contents).map_err(|_| {\n            anyhow::anyhow!(\"Failed to parse configuration; file contents were omitted\")\n        })?;\n        apply_profile(parsed, profile)\n    }\n\n    fn load_with_environment_policy(\n        path: Option<PathBuf>,\n        profile: Option<&str>,\n        environment_policy: ConfigEnvironmentPolicy,\n    ) -> Result<Self> {\n        let path = resolve_load_config_path(path)?;\n        let mut config = if let Some(path) = path.as_ref() {\n            if path.exists() {\n                let contents = fs::read_to_string(path)\n                    .with_context(|| format!(\"Failed to read config file: {}\", path.display()))?;\n                let parsed = Self::from_saved_document(&contents, profile).with_context(|| {\n                    format!(\n                        \"Failed to load config file {}\",\n                        codewhale_config::quote_os_path(path)","sourceCodeStart":4835,"sourceCodeEnd":4871,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L4835-L4871","documentation":"Thrown by `Config::from_saved_document` when persisted configuration text cannot be parsed as TOML into `ConfigFile`. Like the other config parse errors in this codebase, the message intentionally omits the file contents because they may contain secrets; only the failure is reported. Profile precedence is applied only after a successful parse.","triggerScenarios":"Calling `from_saved_document(contents, profile)` (e.g. tests or in-process reloads of saved config) with a `contents` string that `toml::from_str::<ConfigFile>` rejects.","commonSituations":"Loading a config snapshot saved by an older version whose schema has since changed; a corrupted persistence file; programmatically generated TOML with invalid syntax.","solutions":["Validate the saved config text with a TOML parser and fix the syntax/schema error","Regenerate the persisted configuration (delete it and let the app recreate defaults), then re-apply your profile","If the file came from an older version, migrate its keys to the current ConfigFile schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"contents.parse::<toml::Value>().map_err(|e| anyhow!(\"saved config TOML invalid: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match Config::from_saved_document(&saved, profile) {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().starts_with(\"Failed to parse configuration\") => {\n        eprintln!(\"Saved config is not valid TOML; regenerating defaults\");\n        Config::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate TOML before persisting saved configuration snapshots","Version the saved-config schema and migrate on upgrade instead of parsing stale formats"],"tags":["config","toml","parse-error","deserialization"],"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"}