{"record":{"id":"00f05aa3294c7329","repo":"Hmbown/CodeWhale","slug":"failed-to-edit-permissions-at-file-contents-we","errorCode":null,"errorMessage":"failed to edit permissions at {}; file contents were omitted","messagePattern":"failed to edit permissions at (.+?); file contents were omitted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6298,"sourceCode":"    let permissions = if raw.trim().is_empty() {\n        PermissionsToml::default()\n    } else {\n        toml::from_str(&raw).map_err(|_| {\n            anyhow::anyhow!(\n                \"failed to parse permissions at {}; file contents were omitted\",\n                quote_os_path(path)\n            )\n        })?\n    };\n    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();","sourceCodeStart":6280,"sourceCodeEnd":6316,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L6280-L6316","documentation":"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.","triggerScenarios":"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).","commonSituations":"Manually editing permissions.toml with a syntax error, then using the app to add/change permissions; a corrupted file left by a partial write.","solutions":["Fix the TOML syntax error in the permissions file before editing it via the app","Validate the file with a TOML parser to locate the error","Delete the file (or empty it) to start from defaults, then re-add permissions","Restore a valid version from backup or version control"],"exampleFix":"// before\nread = [\"src\"]\nwrite\n// after\nread = [\"src\"]\nwrite = [\"src\"]","handlingStrategy":"validation","validationCode":"let raw = std::fs::read_to_string(&perms_path)?;\nif !raw.trim().is_empty() {\n    raw.parse::<toml_edit::DocumentMut>().map_err(|e| format!(\"invalid TOML: {e}\"))?;\n}","typeGuard":null,"tryCatchPattern":"match edit_permissions(change) {\n    Ok(_) => {},\n    Err(e) => eprintln!(\"{e}; repair the permissions file before editing via the app\"),\n}","preventionTips":["Validate permissions.toml after hand edits before using app edit commands","Keep the file empty or valid — partial writes cause this error","Restore from version control when unsure"],"tags":["toml","permissions","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"}