Hmbown/CodeWhale · error
generated invalid permissions document for
Error message
generated invalid permissions document for {}; file contents were omitted What it means
After the library generates a permissions document body (e.g. from requested permission changes), it re-parses the generated text with toml::from_str::<PermissionsToml> as a self-check. If the generated body fails to deserialize, this error fires with the target path named but contents omitted. This indicates an internal generation bug, not user input.
Solutions
- Upgrade the library to a version fixing the generation bug
- Check whether the requested permission paths contain characters needing TOML escaping and simplify them
- Report a bug including the operation attempted (not the file contents)
- As a workaround, edit the permissions file manually with valid TOML
Defensive patterns
Strategy: try-catch
Validate before calling
// validate the paths being requested are TOML-safe (no unescaped quotes/backslashes)
let safe: Vec<_> = requested_paths.into_iter().filter(|p| !p.contains('"')).collect(); Try / catch
match grant_permissions(paths) {
Ok(_) => {},
Err(e) => { log::error!("generated permissions doc invalid: {e}"); report_bug_with_operation(); }
} Prevention
- Keep the library updated to pick up writer fixes
- Avoid permission paths with characters that need TOML escaping
- Edit the permissions file manually with valid TOML as a workaround
When it happens
Trigger: The permissions-write path calls parse_generated_permissions and its own generated TOML body fails to deserialize — an internal invariant violation in the generation code (bad escaping, wrong types emitted).
Common situations: Library bug emitting invalid TOML for unusual inputs (paths with quotes/backslashes not escaped correctly); version-specific regression in the permissions writer.
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
- failed to edit permissions at
- failed to parse permissions at
- Failed to parse permissions file
- 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/717185b10da3dc4b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/config/src/lib.rs:6308
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();
hasher.update(b"codewhale-permission-removal-v1\0");
hasher.update(quote_os_path(path).as_bytes());
hasher.update(b"\0");
hasher.update(index.to_le_bytes());
hasher.update(b"\0");
hasher.update(raw.as_bytes());
let digest = hasher.finalize();
let mut token = String::with_capacity(24);
for byte in &digest[..12] {
use std::fmt::Write as _;View on GitHub (pinned to 73e0f67d83)