{"record":{"id":"02e711a776bc7b15","repo":"Hmbown/CodeWhale","slug":"the-approval-ui-cannot-persist-deny-rules","errorCode":null,"errorMessage":"the approval UI cannot persist deny rules","messagePattern":"the approval UI cannot persist deny rules","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/ui/session_state.rs","lineNumber":854,"sourceCode":"        }\n    }\n    app.needs_redraw = true;\n}\n\npub(crate) fn persist_rules_from_approval(\n    app: &mut App,\n    config: &mut Config,\n    rules: &[codewhale_config::ToolAskRule],\n) {\n    let action = rules.first().map(|rule| rule.action);\n    match codewhale_config::ConfigStore::load(app.config_path.clone()).and_then(|mut store| {\n        let added = match action {\n            Some(codewhale_execpolicy::PermissionAction::Ask) => store.append_ask_rules(rules)?,\n            Some(codewhale_execpolicy::PermissionAction::Allow) => {\n                store.append_allow_rules(rules)?\n            }\n            Some(codewhale_execpolicy::PermissionAction::Deny) => {\n                anyhow::bail!(\"the approval UI cannot persist deny rules\")\n            }\n            None => 0,\n        };\n        let permissions_path = store.permissions_path();\n        config\n            .exec_policy_engine\n            .set_ruleset(store.permissions().ruleset());\n        Ok((added, permissions_path))\n    }) {\n        Ok((added, path)) if added > 0 => {\n            let action = match action {\n                Some(codewhale_execpolicy::PermissionAction::Allow) => \"allow\",\n                _ => \"ask\",\n            };\n            app.status_message = Some(format!(\n                \"Saved {added} {action} permission rule(s) to {}\",\n                path.display()\n            ));","sourceCodeStart":836,"sourceCodeEnd":872,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/ui/session_state.rs#L836-L872","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","Restrict the approval UI to Ask/Allow persistence and surface a different UX for deny decisions."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if action == Some(codewhale_execpolicy::PermissionAction::Deny) {\n    // skip persist_rules_from_approval; handle deny another way\n}","typeGuard":"fn is_persistable(action: Option<codewhale_execpolicy::PermissionAction>) -> bool {\n    matches!(action, Some(PermissionAction::Ask) | Some(PermissionAction::Allow))\n}","tryCatchPattern":"match apply_approval_decision(decision) {\n    Err(e) if e.to_string().contains(\"cannot persist deny rules\") => handle_deny_in_memory(),\n    other => other?,\n}","preventionTips":["Gate the approval UI's 'always deny' option until deny persistence is implemented.","Only invoke rule persistence for Ask/Allow decisions.","Keep deny handling in a dedicated code path."],"tags":["exec-policy","permissions","approval-ui","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}