Hmbown/CodeWhale · error
unsupported Runtime mode
Error message
unsupported Runtime mode {mode:?}; expected plan, act, or operate What it means
RuntimePolicy::from_request parses the requested mode string with parse_runtime_mode; when it returns None the mode is not one of plan/act/operate and this error is raised. It names the three accepted values so callers can correct the request.
Solutions
- Set the request's mode to exactly one of: plan, act, operate (lowercase).
- Check parse_runtime_mode in runtime_policy.rs for the accepted strings and normalization rules.
- If a legacy mode name is intended, pass it via the legacy alias/auto_approve path rather than the mode field.
- Trim whitespace and lower-case the value before sending if the client derives it from user input.
Example fix
// before
{"mode": "Plan"}
// after
{"mode": "plan"} Defensive patterns
Strategy: validation
Validate before calling
const MODES: [&str; 3] = ["plan", "act", "operate"];
fn valid_mode(mode: &str) -> bool {
MODES.contains(&mode.trim().to_ascii_lowercase().as_str())
} Type guard
fn as_runtime_mode(s: &str) -> Option<&'static str> {
match s {
"plan" => Some("plan"),
"act" => Some("act"),
"operate" => Some("operate"),
_ => None,
}
} Try / catch
match err.to_string().contains("unsupported Runtime mode") {
true => eprintln!("use mode: plan | act | operate"),
false => propagate(err),
} Prevention
- Whitelist the three mode strings in client request builders
- Normalize (trim + lowercase) user-supplied modes before sending
- Migrate legacy mode names at the client boundary
When it happens
Trigger: Creating a RuntimePolicy from an HTTP request (RuntimePolicy::from_request) where the mode field is an unrecognized string — misspelled, capitalized differently, or a legacy value like 'yolo' passed in the mode field instead of via the legacy alias handling.
Common situations: API clients sending "Plan" or "execute" instead of "plan"/"act"/"operate", older scripts using retired mode names, or copy-pasted config values with surrounding whitespace/quotes.
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
- unsupported permission posture
- agent profile reasoning_effort must be one of: inherit…
- Choose approve or decline
- clipboard action must be "read" or "write
- computer action must be list, switch, register, spawn or…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/36f7125ec0c45398.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_policy.rs:68
} else {
ApprovalMode::Suggest
}
});
Self {
mode: parsed_mode,
permission,
}
}
/// Validate and normalize a new Runtime request. Legacy aliases are
/// accepted as one-way inputs, but only current values are persisted.
pub(crate) fn from_request(
mode: &str,
permission_posture: Option<&str>,
auto_approve: Option<bool>,
) -> Result<Self> {
let parsed_mode = parse_runtime_mode(mode).ok_or_else(|| {
anyhow::anyhow!("unsupported Runtime mode {mode:?}; expected plan, act, or operate")
})?;
let permission = match permission_posture {
Some(value) => ApprovalMode::from_config_value(value).ok_or_else(|| {
anyhow::anyhow!(
"unsupported permission posture {value:?}; expected ask, auto-review, or full-access"
)
})?,
None if legacy_yolo_alias(mode) || auto_approve.unwrap_or(false) => ApprovalMode::Bypass,
None => ApprovalMode::Suggest,
};
if permission == ApprovalMode::Never {
bail!("permission posture 'never' is not part of the Runtime product contract");
}
Ok(Self {
mode: parsed_mode,
permission,
})
}View on GitHub (pinned to 73e0f67d83)