Hmbown/CodeWhale · error
Invalid approval_policy
Error message
Invalid approval_policy '{policy}': expected on-request, untrusted, never, auto, or suggest. What it means
The `approval_policy` config field is a closed enum: after trimming and lowercasing it must be one of `on-request`, `untrusted`, `never`, `auto`, or `suggest`. Any other string fails config validation.
Solutions
- Set `approval_policy` to one of: on-request, untrusted, never, auto, suggest.
- Fix casing/spacing — the validator lowercases and trims, so `ON-REQUEST` is fine but `on request` is not.
- Remove the `approval_policy` key entirely if you want the default.
Example fix
// before (config.toml) approval_policy = "on_request" // after approval_policy = "on-request"
Defensive patterns
Strategy: validation
Validate before calling
const APPROVAL_POLICIES: [&str; 5] = ["on-request", "untrusted", "never", "auto", "suggest"];
let normalized = policy.trim().to_ascii_lowercase();
assert!(APPROVAL_POLICIES.contains(&normalized.as_str()), "bad approval_policy: {policy}"); Prevention
- Use the CLI/config UI to set approval_policy rather than hand-editing.
- Remember the value is hyphenated: `on-request`, not `on_request`.
- Omit the key to accept the default instead of guessing a value.
When it happens
Trigger: `Config::validate` encounters an `approval_policy` whose trimmed, ASCII-lowercased value does not match the five accepted literals.
Common situations: Typo like `on_request` (underscore) or `OnRequest` copied with casing conventions from another tool; translating an approval mode from a different CLI whose names differ; hand-editing the config.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Invalid verbosity ' ': expected normal or concise.
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- agent profile reasoning_effort must be one of: inherit…
- api_key cannot be empty string
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/279e5c814d90d392.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config.rs:5166
let provider = self.api_provider();
let known = model_completion_names_for_provider(provider);
let hint = if known.is_empty() {
String::new()
} else {
format!(" (for example: {})", known.join(", "))
};
anyhow::bail!(
"Invalid configured model '{model}' for provider '{}': expected auto or a model ID this provider serves{hint}.",
provider.as_str()
);
}
if let Some(policy) = self.approval_policy.as_deref() {
let normalized = policy.trim().to_ascii_lowercase();
if !matches!(
normalized.as_str(),
"on-request" | "untrusted" | "never" | "auto" | "suggest"
) {
anyhow::bail!(
"Invalid approval_policy '{policy}': expected on-request, untrusted, never, auto, or suggest."
);
}
}
if let Some(v) = self.verbosity.as_deref() {
let normalized = v.trim().to_ascii_lowercase();
if !matches!(normalized.as_str(), "normal" | "concise") {
anyhow::bail!("Invalid verbosity '{v}': expected normal or concise.");
}
}
if let Some(mode) = self.sandbox_mode.as_deref() {
let normalized = mode.trim().to_ascii_lowercase();
if !matches!(
normalized.as_str(),
"read-only" | "workspace-write" | "danger-full-access" | "external-sandbox"
) {
anyhow::bail!(
"Invalid sandbox_mode '{mode}': expected read-only, workspace-write, danger-full-access, or external-sandbox."View on GitHub (pinned to 73e0f67d83)