{"record":{"id":"58df96c52244bdd8","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-requirements-file-file-content","errorCode":null,"errorMessage":"Failed to parse requirements file {}; file contents were omitted","messagePattern":"Failed to parse requirements file (.+?); file contents were omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":11726,"sourceCode":"    configured.is_some_and(|base| !base.trim().is_empty())\n}\n\nfn apply_requirements(config: &mut Config) -> Result<()> {\n    let path = config\n        .requirements_path\n        .as_deref()\n        .map(expand_path)\n        .or_else(default_requirements_path);\n    let Some(path) = path else {\n        return Ok(());\n    };\n    if !path.exists() {\n        return Ok(());\n    }\n    let contents = fs::read_to_string(&path)\n        .with_context(|| format!(\"Failed to read requirements file: {}\", path.display()))?;\n    let requirements: RequirementsFile = toml::from_str(&contents).map_err(|_| {\n        anyhow::anyhow!(\n            \"Failed to parse requirements file {}; file contents were omitted\",\n            codewhale_config::quote_os_path(&path)\n        )\n    })?;\n\n    if !requirements.allowed_approval_policies.is_empty()\n        && let Some(policy) = config.approval_policy.as_ref()\n    {\n        let policy = policy.to_ascii_lowercase();\n        if !requirements\n            .allowed_approval_policies\n            .iter()\n            .any(|p| p.eq_ignore_ascii_case(&policy))\n        {\n            anyhow::bail!(\n                \"approval_policy '{policy}' is not allowed by requirements ({})\",\n                requirements.allowed_approval_policies.join(\", \")\n            );","sourceCodeStart":11708,"sourceCodeEnd":11744,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L11708-L11744","documentation":"Thrown while loading the requirements file: it exists and reads fine, but its contents do not parse as TOML into `RequirementsFile`. As everywhere in this codebase, the parse failure message quotes only the path and omits contents to keep potentially sensitive text out of logs.","triggerScenarios":"Loading the requirements file (e.g. `allowed_approval_policies`) via the TOML parse step; a missing file is silently skipped (`return Ok(())`), so this error only fires on present-but-invalid content.","commonSituations":"Hand-editing the requirements TOML with a syntax slip; a policy tool writing a partially-formatted file; adding an `allowed_approval_policies` entry with unquoted or malformed TOML values.","solutions":["Fix the TOML syntax in the requirements file at the quoted path (validate with a TOML parser)","Check the `allowed_approval_policies` array entries are valid TOML strings","Restore the file from version control or delete it if you do not need requirements overrides (absence is allowed)"],"exampleFix":"// before\nallowed_approval_policies = [untrusted, on-request]\n// after\nallowed_approval_policies = [\"untrusted\", \"on-request\"]","handlingStrategy":"validation","validationCode":"let contents = std::fs::read_to_string(&requirements_path)?;\ncontents.parse::<toml::Value>().map_err(|e| anyhow!(\"requirements TOML invalid: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match load_requirements(&path) {\n    Err(e) if e.to_string().contains(\"Failed to parse requirements file\") => {\n        eprintln!(\"Requirements file invalid at {} — ignoring overrides\", path.display());\n        Ok(())\n    }\n    other => other,\n}","preventionTips":["Quote every entry in `allowed_approval_policies` arrays","Validate the requirements file with a TOML parser after edits","Remember absence of the file is fine — only fix it if you actually need it, or delete it"],"tags":["requirements","toml","parse-error","config"],"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"}