{"record":{"id":"10418214f038adc4","repo":"jdx/mise","slug":"brew-cask-unsupported-kind-run-guard-conditi-104182","errorCode":null,"errorMessage":"brew-cask:{}: unsupported {kind} run guard condition","messagePattern":"brew-cask:(.+?): unsupported (.+?) run guard condition","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/artifacts.rs","lineNumber":983,"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\npub(super) fn 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":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/cask/artifacts.rs#L965-L1001","documentation":"Variant of the unsupported-guard-condition error raised when a cask's `run` guard object exists but has no `condition` key at all (or it is not a string). A guard without a condition is meaningless, so the library bails instead of guessing semantics.","triggerScenarios":"Parsing a cask whose guard object omits `condition`, e.g. {\"value\":\"macos\"} or {\"path\":\"...\",\"base\":\"appdir\"} with no `condition` string.","commonSituations":"Hand-edited or machine-generated cask JSON missing the condition key, casks truncated by a bad fetch/transform, or authors writing a guard expecting an implicit default condition.","solutions":["Add an explicit `condition` key to the guard: \"on\", \"if_exists\", or \"unless_exists\".","If no guard is intended, delete the guard object entirely so the artifact runs unconditionally.","Re-fetch the cask to rule out truncated/corrupted stanza JSON.","Validate the cask stanza against Homebrew's cask DSL schema before installing."],"exampleFix":"// before\n{ \"value\": \"macos\" }\n// after\n{ \"condition\": \"on\", \"value\": \"macos\" }","handlingStrategy":"validation","validationCode":"function guardHasCondition(guard) {\n  return typeof guard === \"object\" && guard !== null && typeof guard.condition === \"string\";\n}","typeGuard":null,"tryCatchPattern":"try {\n  installCask(token);\n} catch (e) {\n  if (String(e).includes(\"run guard condition\") && !String(e).includes(\"{}\")) {\n    // empty-value variant: guard missing condition key\n    console.warn(`Cask ${token} guard is missing its condition; skipping`);\n  } else throw e;\n}","preventionTips":["Always include an explicit condition key in guard objects","Validate cask JSON with a schema requiring `condition` on guard objects","Avoid hand-editing cask stanzas without re-validating"],"tags":["homebrew","cask","parsing","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}