Hmbown/CodeWhale · error
Failed to parse permissions file
Error message
Failed to parse permissions file {}; file contents were omitted What it means
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.
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
Example fix
// before (missing quotes) [[allow]] command = rm -rf // after [[allow]] command = "rm -rf"
Defensive patterns
Strategy: validation
Validate before calling
let raw = std::fs::read_to_string(&permissions_path)?;
raw.parse::<toml::Value>().map_err(|e| anyhow!("permissions TOML invalid: {e}"))?; Try / catch
match load_exec_policy(&permissions_path) {
Err(e) if e.to_string().contains("Failed to parse permissions file") => {
eprintln!("Permissions file invalid; running with empty policy — fix {}");
ExecPolicyEngine::new(Vec::new(), Vec::new())
}
other => other,
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to edit permissions at
- failed to parse permissions at
- generated invalid permissions document for
- Could not parse configuration for route preference…
- Could not parse destination route identity; contents omitted
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/21ec6b8e5b7d4aa7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config.rs:11369
}
fn load_sibling_exec_policy_engine(config_path: Option<&Path>) -> Result<ExecPolicyEngine> {
let Some(config_path) = config_path else {
return Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()));
};
let permissions_path = codewhale_config::permissions_path_for_config_path(config_path);
if !permissions_path.exists() {
return Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()));
}
let raw = fs::read_to_string(&permissions_path).with_context(|| {
format!(
"Failed to read permissions file: {}",
permissions_path.display()
)
})?;
let permissions: codewhale_config::PermissionsToml = toml::from_str(&raw).map_err(|_| {
anyhow::anyhow!(
"Failed to parse permissions file {}; file contents were omitted",
codewhale_config::quote_os_path(&permissions_path)
)
})?;
if permissions.is_empty() {
Ok(ExecPolicyEngine::new(Vec::new(), Vec::new()))
} else {
Ok(ExecPolicyEngine::with_rulesets(vec![permissions.ruleset()]))
}
}
fn merge_skills_config(
base: Option<SkillsConfig>,
override_cfg: Option<SkillsConfig>,
) -> Option<SkillsConfig> {
match (base, override_cfg) {
(None, None) => None,
(Some(base), None) => Some(base),View on GitHub (pinned to 73e0f67d83)