{"record":{"id":"21ec6b8e5b7d4aa7","repo":"Hmbown/CodeWhale","slug":"failed-to-parse-permissions-file-file-contents","errorCode":null,"errorMessage":"Failed to parse permissions file {}; file contents were omitted","messagePattern":"Failed to parse permissions file (.+?); file contents were omitted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":11369,"sourceCode":"}\n\nfn load_sibling_exec_policy_engine(config_path: Option<&Path>) -> Result<ExecPolicyEngine> {\n    let Some(config_path) = config_path else {\n        return Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()));\n    };\n    let permissions_path = codewhale_config::permissions_path_for_config_path(config_path);\n    if !permissions_path.exists() {\n        return Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()));\n    }\n\n    let raw = fs::read_to_string(&permissions_path).with_context(|| {\n        format!(\n            \"Failed to read permissions file: {}\",\n            permissions_path.display()\n        )\n    })?;\n    let permissions: codewhale_config::PermissionsToml = toml::from_str(&raw).map_err(|_| {\n        anyhow::anyhow!(\n            \"Failed to parse permissions file {}; file contents were omitted\",\n            codewhale_config::quote_os_path(&permissions_path)\n        )\n    })?;\n    if permissions.is_empty() {\n        Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()))\n    } else {\n        Ok(ExecPolicyEngine::with_rulesets(vec![permissions.ruleset()]))\n    }\n}\n\nfn merge_skills_config(\n    base: Option<SkillsConfig>,\n    override_cfg: Option<SkillsConfig>,\n) -> Option<SkillsConfig> {\n    match (base, override_cfg) {\n        (None, None) => None,\n        (Some(base), None) => Some(base),","sourceCodeStart":11351,"sourceCodeEnd":11387,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L11351-L11387","documentation":"Thrown when loading the exec permissions file: the file was read successfully, but its contents do not parse as TOML into `codewhale_config::PermissionsToml`. As with other config parse errors, the message reports only the quoted path and omits file contents/keys to avoid leaking anything sensitive.","triggerScenarios":"Building an `ExecPolicyEngine` from a permissions file whose TOML fails `toml::from_str::<PermissionsToml>` (the read itself failing raises the distinct 'Failed to read permissions file' error).","commonSituations":"Hand-editing permissions.toml and breaking syntax (missing bracket on a `[[rule]]` header, unquoted pattern with special characters); a policy-management tool writing invalid TOML; schema drift after an upgrade.","solutions":["Validate and fix the TOML syntax in the permissions file at the reported path","Temporarily move the file aside to confirm the parse error is the cause, then re-add rules incrementally","Check each table header and quoted glob pattern against the PermissionsToml schema"],"exampleFix":"// before (missing quotes)\n[[allow]]\ncommand = rm -rf\n// after\n[[allow]]\ncommand = \"rm -rf\"","handlingStrategy":"validation","validationCode":"let raw = std::fs::read_to_string(&permissions_path)?;\nraw.parse::<toml::Value>().map_err(|e| anyhow!(\"permissions TOML invalid: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match load_exec_policy(&permissions_path) {\n    Err(e) if e.to_string().contains(\"Failed to parse permissions file\") => {\n        eprintln!(\"Permissions file invalid; running with empty policy — fix {}\");\n        ExecPolicyEngine::new(Vec::new(), Vec::new())\n    }\n    other => other,\n}","preventionTips":["Validate permissions.toml with a TOML parser after every hand edit","Quote all command patterns and keep table headers (`[[...]]`) syntactically intact","Store the permissions file in version control for easy revert"],"tags":["permissions","toml","parse-error","policy"],"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"}