Hmbown/CodeWhale · error

the approval UI cannot persist deny rules

Error message

the approval UI cannot persist deny rules

What it means

persist_rules_from_approval supports persisting Ask and Allow rules from the approval UI, but explicitly refuses Deny rules with this error. Deny rules likely have a different persistence semantics (e.g. engine-level deny lists) not supported by the approval-UI write path, so bailing prevents writing a rule the store cannot represent correctly.

Solutions

  1. Handle Deny decisions without calling persist_rules_from_approval (reject in-memory only), or add an explicit append_deny_rules path to the policy store.
  2. If the user intent is 'never ask again and block', implement deny persistence in the exec policy engine rather than the approval store, then extend this match arm.
  3. Restrict the approval UI to Ask/Allow persistence and surface a different UX for deny decisions.
Defensive patterns

Strategy: type-guard

Validate before calling

if action == Some(codewhale_execpolicy::PermissionAction::Deny) {
    // skip persist_rules_from_approval; handle deny another way
}

Type guard

fn is_persistable(action: Option<codewhale_execpolicy::PermissionAction>) -> bool {
    matches!(action, Some(PermissionAction::Ask) | Some(PermissionAction::Allow))
}

Try / catch

match apply_approval_decision(decision) {
    Err(e) if e.to_string().contains("cannot persist deny rules") => handle_deny_in_memory(),
    other => other?,
}

Prevention

When it happens

Trigger: apply_approval_decision is called with a decision whose action is codewhale_execpolicy::PermissionAction::Deny, so persist_rules_from_approval hits the bail branch instead of append_ask_rules/append_allow_rules.

Common situations: A user selects 'always deny' in the approval dialog; the UI passes the decision to apply_approval_decision which attempts to persist rules for a Deny action.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/02e711a776bc7b15. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tui/ui/session_state.rs:854

        }
    }
    app.needs_redraw = true;
}

pub(crate) fn persist_rules_from_approval(
    app: &mut App,
    config: &mut Config,
    rules: &[codewhale_config::ToolAskRule],
) {
    let action = rules.first().map(|rule| rule.action);
    match codewhale_config::ConfigStore::load(app.config_path.clone()).and_then(|mut store| {
        let added = match action {
            Some(codewhale_execpolicy::PermissionAction::Ask) => store.append_ask_rules(rules)?,
            Some(codewhale_execpolicy::PermissionAction::Allow) => {
                store.append_allow_rules(rules)?
            }
            Some(codewhale_execpolicy::PermissionAction::Deny) => {
                anyhow::bail!("the approval UI cannot persist deny rules")
            }
            None => 0,
        };
        let permissions_path = store.permissions_path();
        config
            .exec_policy_engine
            .set_ruleset(store.permissions().ruleset());
        Ok((added, permissions_path))
    }) {
        Ok((added, path)) if added > 0 => {
            let action = match action {
                Some(codewhale_execpolicy::PermissionAction::Allow) => "allow",
                _ => "ask",
            };
            app.status_message = Some(format!(
                "Saved {added} {action} permission rule(s) to {}",
                path.display()
            ));

View on GitHub (pinned to 73e0f67d83)