{"record":{"id":"c09d9a554f71397f","repo":"Hmbown/CodeWhale","slug":"failed-to-update-setting-invalid-mode-value","errorCode":null,"errorMessage":"Failed to update setting: invalid mode '{value}'. Expected: act (agent), plan, or operate.","messagePattern":"Failed to update setting: invalid mode '(.+?)'\\. Expected: act \\(agent\\), plan, or operate\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":1703,"sourceCode":"                let normalized = normalize_synchronized_output(value);\n                if ![\"auto\", \"on\", \"off\"].contains(&normalized) {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid synchronized_output '{value}'. Expected: auto, on, off.\"\n                    );\n                }\n                self.synchronized_output = normalized.to_string();\n            }\n            \"workspace_follow_symlinks\" | \"follow_symlinks\" => {\n                self.workspace_follow_symlinks = parse_bool(value)?;\n            }\n            \"default_mode\" | \"mode\" => {\n                // Act (wire: agent), Plan, and Operate are valid startup modes.\n                // yolo remains a permission-migration alias, not a mode write.\n                self.default_mode = match value.trim().to_ascii_lowercase().as_str() {\n                    \"agent\" | \"normal\" | \"act\" | \"work\" | \"edit\" => \"agent\".to_string(),\n                    \"plan\" => \"plan\".to_string(),\n                    \"operate\" | \"operation\" | \"ops\" => \"operate\".to_string(),\n                    _ => anyhow::bail!(\n                        \"Failed to update setting: invalid mode '{value}'. Expected: act (agent), plan, or operate.\"\n                    ),\n                };\n            }\n            \"context_panel\" | \"context\" | \"session_panel\" => {\n                self.context_panel = parse_bool(value)?;\n            }\n            \"sessions_rail\" | \"sessions_panel\" | \"session_rail\" => {\n                self.sessions_rail = parse_bool(value)?;\n            }\n            \"session_auto_resume\" | \"auto_resume\" => {\n                self.session_auto_resume = parse_bool(value)?;\n            }\n            \"cost_currency\" | \"currency\" => {\n                let Some(currency) = crate::pricing::CostCurrency::from_setting(value) else {\n                    anyhow::bail!(\n                        \"Failed to update setting: invalid cost currency '{value}'. Expected: usd, cny, rmb, yuan.\"\n                    );","sourceCodeStart":1685,"sourceCodeEnd":1721,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L1685-L1721","documentation":"Settings::set's `default_mode`/`mode` arm maps the trimmed, lowercased value through a fixed match: agent/normal/act/work/edit -> \"agent\", plan -> \"plan\", operate/operation/ops -> \"operate\". Any other string hits the catch-all bail. Note `yolo` is intentionally rejected as a mode write — it survives only as a permission-migration alias.","triggerScenarios":"Settings::set(\"mode\", v) with a string outside the alias table, e.g. `mode yolo` (deliberately rejected), `mode planing`, or `mode ACT` only if a future change removes the to_ascii_lowercase normalization.","commonSituations":"Users upgrading from versions where `yolo` was a writable startup mode, or mistyping plan/operate (e.g. `planning`, `operation` is accepted but `operations` is not).","solutions":["Use act (or its aliases agent, normal, work, edit), plan, or operate (or operation, ops).","If you meant the old yolo behavior, configure permission posture / sandbox_mode instead — the comment states yolo is a migration alias, not a mode.","Trim whitespace and mind casing; the match lowercases for you but typos still fail."],"exampleFix":"// before\nsettings.set(\"mode\", \"yolo\")?;\n// after\nsettings.set(\"mode\", \"act\")?;\nsettings.set(\"permission_posture\", \"full-access\")?;","handlingStrategy":"validation","validationCode":"fn valid_mode(v: &str) -> bool {\n    matches!(v.trim().to_ascii_lowercase().as_str(),\n        \"agent\" | \"normal\" | \"act\" | \"work\" | \"edit\" | \"plan\" | \"operate\" | \"operation\" | \"ops\")\n}","typeGuard":null,"tryCatchPattern":"match settings.set(\"mode\", value) {\n    Err(e) if e.to_string().contains(\"invalid mode\") => eprintln!(\"expected act, plan, or operate\"),\n    r => r?,\n}","preventionTips":["Drop `yolo` from migration scripts; it is no longer a writable mode.","Use the canonical short names act/plan/operate.","Trim and lowercase mode strings sourced from env or CLI."],"tags":["rust","configuration","validation"],"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"}