{"record":{"id":"0c2d6f1cf15f162a","repo":"jdx/mise","slug":"brew-cask-unsupported-context-field-0c2d6f","errorCode":null,"errorMessage":"brew-cask: unsupported {context} field {}","messagePattern":"brew-cask: unsupported (.+?) field (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/artifacts.rs","lineNumber":340,"sourceCode":"            arg.as_str()\n                .map(str::to_string)\n                .ok_or_else(|| eyre!(\"brew-cask: {kind} args must be strings\"))\n        })\n        .collect()\n}\n\npub(super) fn reject_unsupported_artifact_fields(\n    context: &str,\n    object: &serde_json::Map<String, Value>,\n    allowed: &[&str],\n) -> Result<()> {\n    let unsupported = object\n        .keys()\n        .filter(|key| !allowed.contains(&key.as_str()))\n        .cloned()\n        .collect::<Vec<_>>();\n    if !unsupported.is_empty() {\n        bail!(\n            \"brew-cask: unsupported {context} field {}\",\n            unsupported.join(\", \")\n        );\n    }\n    Ok(())\n}\n\npub(super) fn parse_generic_artifact(value: &Value) -> Result<Option<GenericArtifact>> {\n    let Some(artifact) = value.as_object().and_then(|object| object.get(\"artifact\")) else {\n        return Ok(None);\n    };\n    let values = artifact\n        .as_array()\n        .ok_or_else(|| eyre!(\"brew-cask: artifact metadata must be an array\"))?;\n    let source = values\n        .first()\n        .and_then(Value::as_str)\n        .ok_or_else(|| eyre!(\"brew-cask: artifact requires a source\"))?;","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/cask/artifacts.rs#L322-L358","documentation":"When parsing a brew cask artifact stanza, mise validates that every TOML/JSON key inside the artifact object is one of the fields allowed for that artifact type (context names which artifact, e.g. 'installer' or 'generate_completions_from_executable'). If any unknown key is present, parsing bails with this error listing the offending keys. It exists so cask artifact definitions stay faithful to Homebrew's schema instead of silently ignoring typos or unsupported options.","triggerScenarios":"A cask artifact object contains a key not in the artifact's allowed set — e.g. an `[[bin]]`/installer-style entry with `args`, `base_name`, or any misspelled field passed through `reject_unsupported_artifact_fields` from `parse_installer_artifact` or `parse_generated_completion_artifact`.","commonSituations":"Typoed field names in a mise-managed cask definition (e.g. `arg` instead of `args`), copying Homebrew Ruby cask stanza fields that the simplified mise schema doesn't support, or adding options to an artifact type that only supports a subset.","solutions":["Remove the unsupported key(s) named in the message from the artifact object.","Check the allowed field list for the artifact type in src/system/packages/brew/cask/artifacts.rs and rename the key to a supported one.","If the field is genuinely needed, the artifact type doesn't model it yet — use a different artifact stanza or file an issue to add support."],"exampleFix":"// before\n[[artifacts.installer]]\nscript = \"install.sh\"\narguements = [\"--user\"]\n// after\n[[artifacts.installer]]\nscript = \"install.sh\"\nargs = [\"--user\"]","handlingStrategy":"validation","validationCode":"const ALLOWED_INSTALLER = new Set([\"script\", \"args\"]);\nconst ALLOWED_COMPLETIONS = new Set([\"executable\", \"args\", \"shells\", \"base_name\"]);\nfunction checkArtifactFields(artifact, allowed) {\n  const bad = Object.keys(artifact).filter((k) => !allowed.has(k));\n  if (bad.length) throw new Error(`brew-cask: unsupported field(s): ${bad.join(\", \")}`);\n}","typeGuard":"function hasOnlyAllowedKeys(obj, allowed) {\n  return obj != null && typeof obj === \"object\" &&\n    Object.keys(obj).every((k) => allowed.includes(k));\n}","tryCatchPattern":"try {\n  parseCaskArtifacts(cask);\n} catch (err) {\n  if (/unsupported .* field/.test(err.message)) {\n    // strip or rename the listed keys before retrying\n  } else throw err;\n}","preventionTips":["Validate cask artifact objects against the allowed field list in CI before committing.","Consult the artifact schema in src/system/packages/brew/cask/artifacts.rs rather than copying Homebrew Ruby cask syntax.","Keep a schema/JSON-Schema file for cask artifacts and lint cask TOML with it."],"tags":["brew-cask","config","schema-validation"],"backgroundTag":"unsupported-config-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}