{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6308,"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":6290,"sourceCodeEnd":6326,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L6290-L6326","documentation":"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.","triggerScenarios":"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).","commonSituations":"Library bug emitting invalid TOML for unusual inputs (paths with quotes/backslashes not escaped correctly); version-specific regression in the permissions writer.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate the paths being requested are TOML-safe (no unescaped quotes/backslashes)\nlet safe: Vec<_> = requested_paths.into_iter().filter(|p| !p.contains('\"')).collect();","typeGuard":null,"tryCatchPattern":"match grant_permissions(paths) {\n    Ok(_) => {},\n    Err(e) => { log::error!(\"generated permissions doc invalid: {e}\"); report_bug_with_operation(); }\n}","preventionTips":["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"],"tags":["toml","permissions","internal","parse-error"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}