{"record":{"id":"61851a5f4c7684d5","repo":"Hmbown/CodeWhale","slug":"persistent-allow-rules-must-match-an-exact-command","errorCode":null,"errorMessage":"persistent allow rules must match an exact command or path","messagePattern":"persistent allow rules must match an exact command or path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":5342,"sourceCode":"    /// this boundary rejects broad or incorrectly typed records so a UI bug\n    /// cannot persist an unscoped allow grant.\n    pub fn append_allow_rules(&mut self, rules: &[ToolAskRule]) -> Result<usize> {\n        for rule in rules {\n            if rule.action != PermissionAction::Allow {\n                bail!(\"append_allow_rules only accepts action = \\\"allow\\\"\");\n            }\n            let Some(workspace) = rule\n                .workspace\n                .as_deref()\n                .and_then(codewhale_execpolicy::normalize_workspace_scope)\n            else {\n                bail!(\"persistent allow rules must be scoped to a workspace\");\n            };\n            if rule.command.is_some() && !rule.command_exact {\n                bail!(\"persistent command allow rules must use exact matching\");\n            }\n            if rule.command.is_none() && rule.path.is_none() {\n                bail!(\"persistent allow rules must match an exact command or path\");\n            }\n            if let Some(command) = rule.command.as_deref()\n                && command.trim().is_empty()\n            {\n                bail!(\"persistent command allow rules must not be empty\");\n            }\n            if let Some(path) = rule.path.as_deref()\n                && codewhale_execpolicy::normalize_workspace_relative_path(path, &workspace)\n                    .is_none_or(|path| path.is_empty())\n            {\n                bail!(\"persistent path allow rules must stay within the workspace\");\n            }\n        }\n        self.append_permission_rules(rules, PermissionAction::Allow)\n    }\n\n    fn append_permission_rules(\n        &mut self,","sourceCodeStart":5324,"sourceCodeEnd":5360,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L5324-L5360","documentation":"A persistent allow rule must constrain something: it needs an exact command or a workspace-relative path. A rule with neither `command` nor `path` set would allow everything, so persistence is refused to avoid silently writing an allow-all rule into the config.","triggerScenarios":"Calling the persistent allow-rule API with a rule where both `command` is `None` and `path` is `None` (regardless of `command_exact`).","commonSituations":"Deserializing a hand-written config entry with only an `action` field; constructing a `PermissionRule` with default field values and only setting `action: Allow`; a tool forwarding an empty rule payload.","solutions":["Populate `command` (with `command_exact: true`) on the rule","Populate `path` with a workspace-relative path the rule should allow","If no constraint is intended, do not persist an allow rule at all"],"exampleFix":"// before\nPermissionRule { action: Allow, command: None, path: None, .. }\n// after\nPermissionRule { action: Allow, command: Some(\"npm test\".into()), command_exact: true, path: None, .. }","handlingStrategy":"validation","validationCode":"fn can_persist(rule: &PermissionRule) -> bool {\n    rule.command.is_some() || rule.path.is_some()\n}","typeGuard":"fn has_constraint(rule: &PermissionRule) -> bool {\n    rule.command.is_some() || rule.path.is_some()\n}","tryCatchPattern":"match config.append_persistent_allow_rules(&rules) {\n    Err(e) if e.to_string().contains(\"exact command or path\") => {\n        // drop or fill in the empty rule, then retry\n    }\n    result => result?,\n}","preventionTips":["Never build `PermissionRule` values from defaults without setting `command` or `path`","Validate rules at construction time in your own builder","Reject rule payloads at your UI/CLI boundary when both fields are absent"],"tags":["config","permissions","validation"],"backgroundTag":"missing-required-argument","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"}