Hmbown/CodeWhale · error · anyhow::Error
generated invalid permissions document for {}; file contents
Error message
generated invalid permissions document for {}; file contents were omitted What it means
After building the new permissions document text, the code round-trips it through toml::from_str to prove the generated output is valid before persisting. This error means Codewhale itself generated an invalid permissions document: an internal bug. The write is aborted, leaving the on-disk file untouched.
Source
Thrown at crates/config/src/lib.rs:6068
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 8880682c63)
Solutions
- Report upstream with the exact permissions operation attempted; on-disk state is safe because the write was refused
- Retry with fewer or simpler permission changes to identify the trigger
- Update to a patched release (or pin a known-good older one) once the bug is confirmed
Defensive patterns
Strategy: try-catch
Try / catch
Catch this specific message, treat it as an internal bug, and report the triggering permission operation. The write was refused, so no rollback is needed; surface a clear 'state unchanged' signal to the user.
Prevention
- Pin a known-good version when a generated-permissions bug is announced
- Reproduce with minimal permission changes before reporting to give maintainers a deterministic case
When it happens
Trigger: A permissions edit whose serialization produces text that no longer parses back into PermissionsToml (for example a new permission shape not covered by the TOML schema). It is not caused by anything in the user's file.
Common situations: Version upgrades adding new permission kinds; a deterministic reproduction with the same operation indicates a real bug in the generation code.
Related errors
- failed to parse serialized config for comment merge; file co
- failed to parse permissions at {}; file contents were omitte
- failed to edit permissions at {}; file contents were omitted
- write-capable Fleet worker '{}' has no launch manifest
- unavailable credential
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/717185b10da3dc4b.
Report an issue: GitHub.