{"record":{"id":"ccf38c5bd18f3df5","repo":"jdx/mise","slug":"brew-cask-unsupported-kind-sudo-setting","errorCode":null,"errorMessage":"brew-cask:{}: unsupported {kind} sudo setting","messagePattern":"brew-cask:(.+?): unsupported (.+?) sudo setting","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":5800,"sourceCode":"                must_succeed,\n                notices,\n                failure_message,\n            })\n        }\n        _ => bail!(\n            \"brew-cask:{}: unsupported {kind} step type {}\",\n            cask.token,\n            step_type\n        ),\n    }\n}\n\nfn parse_flight_sudo(cask: &Cask, kind: &str, value: Option<&Value>) -> Result<FlightSudo> {\n    match value {\n        None | Some(Value::Bool(false)) => Ok(FlightSudo::Never),\n        Some(Value::Bool(true)) => Ok(FlightSudo::Always),\n        Some(Value::String(value)) if value == \"if_needed\" => Ok(FlightSudo::IfNeeded),\n        _ => bail!(\"brew-cask:{}: unsupported {kind} sudo setting\", cask.token),\n    }\n}\n\nfn parse_flight_guards(cask: &Cask, kind: &str, value: Option<&Value>) -> Result<Vec<FlightGuard>> {\n    value\n        .map(|guards| {\n            guards\n                .as_array()\n                .ok_or_else(|| {\n                    eyre!(\n                        \"brew-cask:{}: unsupported {kind} guards metadata format\",\n                        cask.token\n                    )\n                })?\n                .iter()\n                .map(|guard| parse_flight_guard(cask, kind, guard))\n                .collect::<Result<Vec<_>>>()\n        })","sourceCodeStart":5782,"sourceCodeEnd":5818,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5782-L5818","documentation":"Thrown by parse_flight_sudo for the sudo setting of run steps. Accepted forms are exactly: absent or false (never sudo), true (always sudo), and the string \"if_needed\" (sudo only when the command fails without it). Any other value — \"always\", 1, \"IfNeeded\", null-as-string — falls to the wildcard arm.","triggerScenarios":"A run step in preflight_steps/postflight_steps with \"sudo\": \"always\" / \"sudo\": 1 / \"sudo\": \"yes\"; parse_flight_sudo is called with that Option<&Value> and matches none of the three accepted arms.","commonSituations":"Assuming boolean-ish strings are coerced; copying sudo syntax from Homebrew's installer stanza (which uses different conventions); casing differences like \"If_Needed\".","solutions":["Use \"sudo\": true for always, \"sudo\": false (or omit) for never","Use the exact lowercase string \"sudo\": \"if_needed\" for conditional sudo"],"exampleFix":"// before\n{\"type\": \"run\", \"command\": {...}, \"sudo\": \"always\"}\n// after\n{\"type\": \"run\", \"command\": {...}, \"sudo\": true}","handlingStrategy":"validation","validationCode":"fn sudo_ok(step: &serde_json::Value) -> bool {\n    match step.get(\"sudo\") {\n        None | Some(serde_json::Value::Bool(_)) => true,\n        Some(serde_json::Value::String(s)) => s == \"if_needed\",\n        Some(_) => false,\n    }\n}","typeGuard":"fn is_valid_sudo(v: &serde_json::Value) -> bool {\n    v.is_boolean() || v.as_str() == Some(\"if_needed\")\n}","tryCatchPattern":"match parse_flight_step(&cask, kind, &step) {\n    Ok(step) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"sudo setting\") => {\n        eprintln!(\"sudo accepts true, false, or \\\"if_needed\\\" only\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use booleans for always/never sudo; the exact string \"if_needed\" for conditional","Do not copy sudo syntax from other tools' configs"],"tags":["brew-cask","mise","sudo","enum-validation","flight-steps"],"backgroundTag":"brew-cask-stanza-validation","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}