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

  1. Validate and fix the TOML syntax in the permissions file at the reported path
  2. Temporarily move the file aside to confirm the parse error is the cause, then re-add rules incrementally
  3. 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

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

Related errors


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)