{"record":{"id":"dd77164a18460778","repo":"jdx/mise","slug":"brew-cask-unsupported-kind-run-guard-conditi-dd7716","errorCode":null,"errorMessage":"brew-cask:{}: unsupported {kind} run guard condition","messagePattern":"brew-cask:(.+?): unsupported (.+?) run guard condition","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":5930,"sourceCode":"            None => bail!(\n                \"brew-cask:{}: unsupported {kind} run guard platform\",\n                cask.token\n            ),\n        },\n        Some(condition @ (\"if_exists\" | \"unless_exists\")) => {\n            let path = parse_context_flight_path(cask, kind, \"run guard\", object)?;\n            if condition == \"if_exists\" {\n                Ok(FlightGuard::IfExists(path))\n            } else {\n                Ok(FlightGuard::UnlessExists(path))\n            }\n        }\n        Some(condition) => bail!(\n            \"brew-cask:{}: unsupported {kind} run guard condition {}\",\n            cask.token,\n            condition\n        ),\n        None => bail!(\n            \"brew-cask:{}: unsupported {kind} run guard condition\",\n            cask.token\n        ),\n    }\n}\n\nfn parse_context_flight_path(\n    cask: &Cask,\n    kind: &str,\n    field: &str,\n    object: &serde_json::Map<String, Value>,\n) -> Result<FlightPath> {\n    let path = object\n        .get(\"path\")\n        .and_then(Value::as_str)\n        .ok_or_else(|| eyre!(\"brew-cask:{}: unsupported {kind} {field} path\", cask.token))?;\n    let base = match object.get(\"base\").and_then(Value::as_str) {\n        Some(\"staged_path\") => FlightPathBase::StagedPath,","sourceCodeStart":5912,"sourceCodeEnd":5948,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5912-L5948","documentation":"Thrown when a guard object has no readable condition at all: object.get(\"condition\").and_then(as_str) returns None because the key is absent or holds a non-string. Without a condition the guard cannot be classified, so parsing the whole cask fails. The message has no value placeholder, distinguishing it from the unknown-condition-string variant.","triggerScenarios":"{\"guards\": [{\"path\": \"/tmp/x\"}]} — a guard with path fields but no \"condition\" key; or {\"condition\": [\"on\"]} where condition is an array.","commonSituations":"Typing the key wrongly (\"conditions\", \"when\", \"check\"); templating that drops empty condition variables; refactors that renamed the field.","solutions":["Add \"condition\" as one of \"on\", \"if_exists\", \"unless_exists\"","If the guard was meant to be a platform check, also add the matching \"value\""],"exampleFix":"// before\n{\"guards\": [{\"path\": \"/tmp/lock\"}]}\n// after\n{\"guards\": [{\"condition\": \"unless_exists\", \"path\": \"/tmp/lock\"}]}","handlingStrategy":"validation","validationCode":"fn guard_has_condition(g: &serde_json::Value) -> bool {\n    g.get(\"condition\").and_then(|c| c.as_str()).is_some()\n}","typeGuard":null,"tryCatchPattern":"match parse_flight_guard(&cask, kind, &guard) {\n    Ok(g) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"run guard condition\") && !e.to_string().contains(\"condition \") => {\n        eprintln!(\"every guard object needs a string 'condition' key\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always include a string 'condition' as the first key of a guard","Lint generated cask JSON for guard objects that lack a condition"],"tags":["brew-cask","mise","guards","missing-field","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"}