{"record":{"id":"6d6f14c9683f0a24","repo":"Hmbown/CodeWhale","slug":"approval-policy-policy-is-not-allowed-by-requi","errorCode":null,"errorMessage":"approval_policy '{policy}' is not allowed by requirements ({})","messagePattern":"approval_policy '(.+?)' is not allowed by requirements \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":11741,"sourceCode":"    let contents = fs::read_to_string(&path)\n        .with_context(|| format!(\"Failed to read requirements file: {}\", path.display()))?;\n    let requirements: RequirementsFile = toml::from_str(&contents).map_err(|_| {\n        anyhow::anyhow!(\n            \"Failed to parse requirements file {}; file contents were omitted\",\n            codewhale_config::quote_os_path(&path)\n        )\n    })?;\n\n    if !requirements.allowed_approval_policies.is_empty()\n        && let Some(policy) = config.approval_policy.as_ref()\n    {\n        let policy = policy.to_ascii_lowercase();\n        if !requirements\n            .allowed_approval_policies\n            .iter()\n            .any(|p| p.eq_ignore_ascii_case(&policy))\n        {\n            anyhow::bail!(\n                \"approval_policy '{policy}' is not allowed by requirements ({})\",\n                requirements.allowed_approval_policies.join(\", \")\n            );\n        }\n    }\n    if !requirements.allowed_sandbox_modes.is_empty()\n        && let Some(mode) = config.sandbox_mode.as_ref()\n    {\n        let mode = mode.to_ascii_lowercase();\n        if !requirements\n            .allowed_sandbox_modes\n            .iter()\n            .any(|m| m.eq_ignore_ascii_case(&mode))\n        {\n            anyhow::bail!(\n                \"sandbox_mode '{mode}' is not allowed by requirements ({})\",\n                requirements.allowed_sandbox_modes.join(\", \")\n            );","sourceCodeStart":11723,"sourceCodeEnd":11759,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L11723-L11759","documentation":"The TUI config loader validates the user's `approval_policy` against an explicit allowlist in a requirements block. If the policy value (case-insensitively compared) is not present in `requirements.allowed_approval_policies`, configuration loading aborts rather than proceeding with an unapproved policy. This guards deployments where requirements restrict which approval modes are permitted.","triggerScenarios":"Calling config validation with an `approval_policy` string (e.g. `untrusted`, `on-request`, `on-failure`, `never`) that is absent from a non-empty `requirements.allowed_approval_policies` list.","commonSituations":"Hand-edited config.toml with a typo'd or renamed approval policy; switching between Codewhale versions where a policy name changed; org-managed requirements files that whitelist only a subset of policies.","solutions":["Set `approval_policy` to one of the allowed values listed in the error's parenthesized list","Remove or update the `requirements.allowed_approval_policies` restriction if the policy should be permitted","Fix the spelling/case of the policy in your config (matching is case-insensitive, so this is a value mistake not formatting)"],"exampleFix":"// before\napproval_policy = \"auto\"\n// after\napproval_policy = \"on-request\"","handlingStrategy":"validation","validationCode":"let allowed = requirements.allowed_approval_policies.iter().any(|p| p.eq_ignore_ascii_case(&policy));\nif requirements_has_allowlist && !allowed { eprintln!(\"policy {policy} not in {:?}\", requirements.allowed_approval_policies); }","typeGuard":"fn policy_allowed(policy: &str, requirements: &Requirements) -> bool {\n    requirements.allowed_approval_policies.is_empty()\n        || requirements.allowed_approval_policies.iter().any(|p| p.eq_ignore_ascii_case(policy))\n}","tryCatchPattern":null,"preventionTips":["Keep approval_policy values in sync with the requirements allowlist","Copy allowed values directly from the error message list","Validate config after any requirements-file update"],"tags":["config","validation","approval-policy"],"backgroundTag":"invalid-config-value","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"}