{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":5267,"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":5249,"sourceCodeEnd":5285,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/config/src/lib.rs#L5249-L5285","documentation":"append_allow_rules (crates/config/src/lib.rs:5267) rejects an allow rule with neither command nor path set. A tool-only allow ('always allow Bash') is too broad to persist, so at least one exact matcher (command or path) is mandatory; otherwise the bail fires before anything is written.","triggerScenarios":"A ToolAskRule with command = None and path = None (tool-scoped blanket approval) passed to append_allow_rules.","commonSituations":"User clicks 'always allow this tool' and the caller tries to persist it without a matcher; rules built from a template that leaves both optional fields empty.","solutions":["Scope the rule: attach the exact command or the workspace-relative path that was approved","Keep blanket tool approvals session-only","Offer 'always allow <tool> <command>' phrasing in the prompt UI so persisted rules always carry a matcher"],"exampleFix":"// before\nlet rule = ToolAskRule { command: None, path: None, tool: tool.clone(), /* ... */ };\n\n// after\nlet rule = ToolAskRule { command: Some(\"cargo test\".into()), path: None, tool: tool.clone(), /* ... */ };","handlingStrategy":"validation","validationCode":"assert!(rule.command.is_some() || rule.path.is_some()); // tool-only rules cannot persist","typeGuard":"fn has_persistable_matcher(rule: &ToolAskRule) -> bool {\n    rule.command.is_some() || rule.path.is_some()\n}","tryCatchPattern":null,"preventionTips":["Design prompts so persisted approvals always name a command or path","Check both optional fields before building the persist call","Keep tool-wide approvals in session memory only"],"tags":["rust","permissions","security","validation"],"backgroundTag":"permission-rule-validation-failed","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}