{"record":{"id":"717185b10da3dc4b","repo":"Hmbown/CodeWhale","slug":"generated-invalid-permissions-document-for-fil","errorCode":null,"errorMessage":"generated invalid permissions document for {}; file contents were omitted","messagePattern":"generated invalid permissions document for (.+?); file contents were omitted","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6068,"sourceCode":"    Ok((file_exists, raw, permissions))\n}\n\nfn parse_permissions_document(path: &Path, raw: &str) -> Result<toml_edit::DocumentMut> {\n    if raw.trim().is_empty() {\n        Ok(toml_edit::DocumentMut::new())\n    } else {\n        raw.parse::<toml_edit::DocumentMut>().map_err(|_| {\n            anyhow::anyhow!(\n                \"failed to edit permissions at {}; file contents were omitted\",\n                quote_os_path(path)\n            )\n        })\n    }\n}\n\nfn parse_generated_permissions(path: &Path, body: &str) -> Result<PermissionsToml> {\n    toml::from_str(body).map_err(|_| {\n        anyhow::anyhow!(\n            \"generated invalid permissions document for {}; file contents were omitted\",\n            quote_os_path(path)\n        )\n    })\n}\n\nfn permission_removal_token(path: &Path, raw: &str, index: usize) -> String {\n    let mut hasher = Sha256::new();\n    hasher.update(b\"codewhale-permission-removal-v1\\0\");\n    hasher.update(quote_os_path(path).as_bytes());\n    hasher.update(b\"\\0\");\n    hasher.update(index.to_le_bytes());\n    hasher.update(b\"\\0\");\n    hasher.update(raw.as_bytes());\n    let digest = hasher.finalize();\n    let mut token = String::with_capacity(24);\n    for byte in &digest[..12] {\n        use std::fmt::Write as _;","sourceCodeStart":6050,"sourceCodeEnd":6086,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/config/src/lib.rs#L6050-L6086","documentation":"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.","triggerScenarios":"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.","commonSituations":"Version upgrades adding new permission kinds; a deterministic reproduction with the same operation indicates a real bug in the generation code.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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.","preventionTips":["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"],"tags":["permissions","toml","invariant","internal-bug"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}