{"record":{"id":"36f7125ec0c45398","repo":"Hmbown/CodeWhale","slug":"unsupported-runtime-mode-mode-expected-plan","errorCode":null,"errorMessage":"unsupported Runtime mode {mode:?}; expected plan, act, or operate","messagePattern":"unsupported Runtime mode (.+?); expected plan, act, or operate","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_policy.rs","lineNumber":68,"sourceCode":"                } else {\n                    ApprovalMode::Suggest\n                }\n            });\n        Self {\n            mode: parsed_mode,\n            permission,\n        }\n    }\n\n    /// Validate and normalize a new Runtime request. Legacy aliases are\n    /// accepted as one-way inputs, but only current values are persisted.\n    pub(crate) fn from_request(\n        mode: &str,\n        permission_posture: Option<&str>,\n        auto_approve: Option<bool>,\n    ) -> Result<Self> {\n        let parsed_mode = parse_runtime_mode(mode).ok_or_else(|| {\n            anyhow::anyhow!(\"unsupported Runtime mode {mode:?}; expected plan, act, or operate\")\n        })?;\n        let permission = match permission_posture {\n            Some(value) => ApprovalMode::from_config_value(value).ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"unsupported permission posture {value:?}; expected ask, auto-review, or full-access\"\n                )\n            })?,\n            None if legacy_yolo_alias(mode) || auto_approve.unwrap_or(false) => ApprovalMode::Bypass,\n            None => ApprovalMode::Suggest,\n        };\n        if permission == ApprovalMode::Never {\n            bail!(\"permission posture 'never' is not part of the Runtime product contract\");\n        }\n        Ok(Self {\n            mode: parsed_mode,\n            permission,\n        })\n    }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_policy.rs#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"mode\": \"Plan\"}\n\n// after\n{\"mode\": \"plan\"}","handlingStrategy":"validation","validationCode":"const MODES: [&str; 3] = [\"plan\", \"act\", \"operate\"];\nfn valid_mode(mode: &str) -> bool {\n    MODES.contains(&mode.trim().to_ascii_lowercase().as_str())\n}","typeGuard":"fn as_runtime_mode(s: &str) -> Option<&'static str> {\n    match s {\n        \"plan\" => Some(\"plan\"),\n        \"act\" => Some(\"act\"),\n        \"operate\" => Some(\"operate\"),\n        _ => None,\n    }\n}","tryCatchPattern":"match err.to_string().contains(\"unsupported Runtime mode\") {\n    true => eprintln!(\"use mode: plan | act | operate\"),\n    false => propagate(err),\n}","preventionTips":["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"],"tags":["runtime-api","validation","enum"],"backgroundTag":"invalid-enum-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"}