Hmbown/CodeWhale · error
persistent allow rules must match an exact command or path
Error message
persistent allow rules must match an exact command or path
What it means
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.
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
Example fix
// before
PermissionRule { action: Allow, command: None, path: None, .. }
// after
PermissionRule { action: Allow, command: Some("npm test".into()), command_exact: true, path: None, .. } Defensive patterns
Strategy: validation
Validate before calling
fn can_persist(rule: &PermissionRule) -> bool {
rule.command.is_some() || rule.path.is_some()
} Type guard
fn has_constraint(rule: &PermissionRule) -> bool {
rule.command.is_some() || rule.path.is_some()
} Try / catch
match config.append_persistent_allow_rules(&rules) {
Err(e) if e.to_string().contains("exact command or path") => {
// drop or fill in the empty rule, then retry
}
result => result?,
} Prevention
- 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
When it happens
Trigger: Calling the persistent allow-rule API with a rule where both `command` is `None` and `path` is `None` (regardless of `command_exact`).
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- persistent command allow rules must use exact matching
- persistent path allow rules must stay within the workspace
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- agent profile tools.posture= would widen permissions; use…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/61851a5f4c7684d5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/config/src/lib.rs:5342
/// this boundary rejects broad or incorrectly typed records so a UI bug
/// cannot persist an unscoped allow grant.
pub fn append_allow_rules(&mut self, rules: &[ToolAskRule]) -> Result<usize> {
for rule in rules {
if rule.action != PermissionAction::Allow {
bail!("append_allow_rules only accepts action = \"allow\"");
}
let Some(workspace) = rule
.workspace
.as_deref()
.and_then(codewhale_execpolicy::normalize_workspace_scope)
else {
bail!("persistent allow rules must be scoped to a workspace");
};
if rule.command.is_some() && !rule.command_exact {
bail!("persistent command allow rules must use exact matching");
}
if rule.command.is_none() && rule.path.is_none() {
bail!("persistent allow rules must match an exact command or path");
}
if let Some(command) = rule.command.as_deref()
&& command.trim().is_empty()
{
bail!("persistent command allow rules must not be empty");
}
if let Some(path) = rule.path.as_deref()
&& codewhale_execpolicy::normalize_workspace_relative_path(path, &workspace)
.is_none_or(|path| path.is_empty())
{
bail!("persistent path allow rules must stay within the workspace");
}
}
self.append_permission_rules(rules, PermissionAction::Allow)
}
fn append_permission_rules(
&mut self,View on GitHub (pinned to 73e0f67d83)