Hmbown/CodeWhale · error

failed to edit permissions at

Error message

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

What it means

parse_permissions_document parses the permissions file with toml_edit::DocumentMut for surgical edits that preserve formatting and comments. If the non-empty raw text is not valid TOML, this sanitized error is thrown.

Solutions

  1. Fix the TOML syntax error in the permissions file before editing it via the app
  2. Validate the file with a TOML parser to locate the error
  3. Delete the file (or empty it) to start from defaults, then re-add permissions
  4. Restore a valid version from backup or version control

Example fix

// before
read = ["src"]
write
// after
read = ["src"]
write = ["src"]
Defensive patterns

Strategy: validation

Validate before calling

let raw = std::fs::read_to_string(&perms_path)?;
if !raw.trim().is_empty() {
    raw.parse::<toml_edit::DocumentMut>().map_err(|e| format!("invalid TOML: {e}"))?;
}

Try / catch

match edit_permissions(change) {
    Ok(_) => {},
    Err(e) => eprintln!("{e}; repair the permissions file before editing via the app"),
}

Prevention

When it happens

Trigger: Calling the permissions-edit path (via parse_permissions_document) when the existing permissions file contains invalid TOML (empty files are fine and yield a fresh document).

Common situations: Manually editing permissions.toml with a syntax error, then using the app to add/change permissions; a corrupted file left by a partial write.

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/00f05aa3294c7329. Report an issue: GitHub.

Appendix: source

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

    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)
            )
        })
    }
}

fn parse_generated_permissions(path: &Path, body: &str) -> Result<PermissionsToml> {
    toml::from_str(body).map_err(|_| {
        anyhow::anyhow!(
            "generated invalid permissions document for {}; file contents were omitted",
            quote_os_path(path)
        )
    })
}

fn permission_removal_token(path: &Path, raw: &str, index: usize) -> String {
    let mut hasher = Sha256::new();

View on GitHub (pinned to 73e0f67d83)