{"record":{"id":"7f6d237d3c2db9d9","repo":"Hmbown/CodeWhale","slug":"persistent-command-allow-rules-must-not-be-empty","errorCode":null,"errorMessage":"persistent command allow rules must not be empty","messagePattern":"persistent command allow rules must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":5347,"sourceCode":"                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,\n        rules: &[ToolAskRule],\n        expected_action: PermissionAction,\n    ) -> Result<usize> {\n        if rules.is_empty() {\n            return Ok(0);","sourceCodeStart":5329,"sourceCodeEnd":5365,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L5329-L5365","documentation":"A persistent allow rule whose command is present but empty (or only whitespace) is meaningless and dangerous — it would match nothing useful or act as a wildcard depending on the matcher. The library rejects empty/whitespace command strings before writing the rule to the permissions config.","triggerScenarios":"Calling the persistent allow-rule API with `command: Some(\"\")` or `Some(\"   \")` (whitespace-only) and `command_exact: true`.","commonSituations":"A UI or CLI passing an unfilled command input through to persistence; trimming logic stripping a command down to empty before the rule is saved; template/stub rules left unfilled in config.","solutions":["Provide the actual command string in `command` before persisting","Skip persistence entirely when the command input is blank","If only a path constraint is intended, remove the empty `command` and set `path` instead"],"exampleFix":"// before\nlet rule = PermissionRule { command: Some(input.trim().into()), command_exact: true, .. }; // input was blank\n// after\nif !input.trim().is_empty() {\n    let rule = PermissionRule { command: Some(input.trim().into()), command_exact: true, .. };\n}\n","handlingStrategy":"validation","validationCode":"fn has_nonempty_command(rule: &PermissionRule) -> bool {\n    rule.command.as_deref().map_or(true, |c| !c.trim().is_empty())\n}","typeGuard":"fn is_blank_command(rule: &PermissionRule) -> bool {\n    rule.command.as_deref().is_some_and(|c| c.trim().is_empty())\n}","tryCatchPattern":"match config.append_persistent_allow_rules(&rules) {\n    Err(e) if e.to_string().contains(\"must not be empty\") => {\n        // filter out rules with blank commands and retry\n    }\n    result => result?,\n}","preventionTips":["Skip persistence when a command input trims to empty","Trim and check command strings before wrapping them in a rule","Treat blank input as 'no rule' rather than an empty-command rule"],"tags":["config","permissions","empty-value"],"backgroundTag":"empty-required-field","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"}