Hmbown/CodeWhale · error

failed to parse permissions at

Error message

failed to parse permissions at {}; file contents were omitted

What it means

Loading the permissions file deserializes its TOML into PermissionsToml; on failure the error reports only the path, omitting file contents. Empty files are treated as default permissions and do not error — only non-empty invalid TOML reaches this error.

Solutions

  1. Fix the TOML syntax/type error in the permissions file at the quoted path
  2. Check field types against the PermissionsToml schema (strings vs arrays vs tables)
  3. Validate the file with a TOML parser or against a known-good permissions file
  4. Reset the permissions file to empty (grants defaults) and re-add entries incrementally

Example fix

// before (wrong type)
read = ".env"
// after
read = [".env", "src/**"]
Defensive patterns

Strategy: validation

Validate before calling

let raw = std::fs::read_to_string(&perms_path)?;
if !raw.trim().is_empty() {
    toml::from_str::<PermissionsToml>(&raw).map_err(|e| format!("bad permissions file: {e}"))?;
}

Try / catch

match load_permissions() {
    Ok(p) => apply(p),
    Err(e) => eprintln!("{e}; fix types/syntax in the permissions file"),
}

Prevention

When it happens

Trigger: toml::from_str::<PermissionsToml> on the contents of the permissions file when it contains syntactically invalid TOML or fields with wrong types/unknown values.

Common situations: Hand-edited permissions file with a typo, wrong data type (e.g. string where array expected), unknown permission key, or missing quotes around paths containing special characters.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/f954cc33814f24ac. Report an issue: GitHub.

Appendix: source

Thrown at crates/config/src/lib.rs:6284

fn load_sibling_permissions(config_path: &Path) -> Result<PermissionsToml> {
    let permissions_path = checked_permissions_path_for_config_path(config_path)?;
    let (_, _, permissions) = read_permissions_state(&permissions_path)?;
    Ok(permissions)
}

fn read_permissions_state(path: &Path) -> Result<(bool, String, PermissionsToml)> {
    let file_exists = checked_path_exists(path)?;
    let raw = if file_exists {
        read_checked_permissions_file(path)?
    } else {
        String::new()
    };
    let permissions = if raw.trim().is_empty() {
        PermissionsToml::default()
    } else {
        toml::from_str(&raw).map_err(|_| {
            anyhow::anyhow!(
                "failed to parse permissions at {}; file contents were omitted",
                quote_os_path(path)
            )
        })?
    };
    Ok((file_exists, raw, permissions))
}

fn parse_permissions_document(path: &Path, raw: &str) -> Result<toml_edit::DocumentMut> {
    if raw.trim().is_empty() {
        Ok(toml_edit::DocumentMut::new())
    } else {
        raw.parse::<toml_edit::DocumentMut>().map_err(|_| {
            anyhow::anyhow!(
                "failed to edit permissions at {}; file contents were omitted",
                quote_os_path(path)
            )
        })

View on GitHub (pinned to 73e0f67d83)