{"record":{"id":"cc5ceefe590beafa","repo":"jdx/mise","slug":"brew-cask-unsupported-kind-run-guard-conditi","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":5925,"sourceCode":"            Some(value) => bail!(\n                \"brew-cask:{}: unsupported {kind} run guard platform {}\",\n                cask.token,\n                value\n            ),\n            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","sourceCodeStart":5907,"sourceCodeEnd":5943,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5907-L5943","documentation":"Thrown when a run/copy guard has a condition string mise does not implement. Recognized conditions are exactly \"on\" (platform), \"if_exists\", and \"unless_exists\" (path existence). Conditions like \"if_running\", \"unless_changed\", or \"if\" land in this arm and bail with the condition echoed.","triggerScenarios":"{\"guards\": [{\"condition\": \"if_running\", \"value\": \"com.apple.x\"}]} on a run or copy step inside preflight_steps/postflight_steps.","commonSituations":"Porting Homebrew Ruby DSL concepts (only_if/unless_method, launchctl checks) that have no JSON equivalent; inventing conditions beyond the implemented trio; version skew with newer Homebrew metadata.","solutions":["Express platform checks as {\"condition\": \"on\", \"value\": \"macos\"|\"linux\"}","Express file checks as {\"condition\": \"if_exists\"|\"unless_exists\", \"path\": ..., \"base\": ...}","If the guard cannot be expressed, remove it and update mise / report the cask token upstream"],"exampleFix":"// before\n{\"condition\": \"if\", \"value\": \"macos\"}\n// after\n{\"condition\": \"on\", \"value\": \"macos\"}","handlingStrategy":"validation","validationCode":"fn guard_condition_ok(g: &serde_json::Value) -> bool {\n    matches!(g.get(\"condition\").and_then(|c| c.as_str()), None | Some(\"on\") | Some(\"if_exists\") | Some(\"unless_exists\"))\n}","typeGuard":"fn is_supported_condition(v: &serde_json::Value) -> bool {\n    v.as_str().map(|c| [\"on\", \"if_exists\", \"unless_exists\"].contains(&c)).unwrap_or(false)\n}","tryCatchPattern":"match parse_flight_guard(&cask, kind, &guard) {\n    Ok(g) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"run guard condition\") => {\n        eprintln!(\"guard conditions are limited to on / if_exists / unless_exists\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Do not invent conditions; only on, if_exists, unless_exists exist","Re-express richer logic as a run step with a shell script"],"tags":["brew-cask","mise","guards","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"}