jdx/mise · error

brew-cask: unsupported {context} field {}

Error message

brew-cask: unsupported {context} field {}

What it means

Generic field validator for cask artifacts: given an object, a context label, and an allow-list of keys, it bails listing any keys outside the allow-list. Used by parse_installer_artifact and parse_generated_completion_artifact to reject unknown fields.

Source

Thrown at src/system/packages/brew/cask/artifacts.rs:339

        .map(|arg| {
            arg.as_str()
                .map(str::to_string)
                .ok_or_else(|| eyre!("brew-cask: {kind} args must be strings"))
        })
        .collect()
}

pub(super) fn reject_unsupported_artifact_fields(
    context: &str,
    object: &serde_json::Map<String, Value>,
    allowed: &[&str],
) -> Result<()> {
    let unsupported = object
        .keys()
        .filter(|key| !allowed.contains(&key.as_str()))
        .cloned()
        .collect::<Vec<_>>();
    if !unsupported.is_empty() {
        bail!(
            "brew-cask: unsupported {context} field {}",
            unsupported.join(", ")
        );
    }
    Ok(())
}

pub(super) fn parse_generic_artifact(value: &Value) -> Result<Option<GenericArtifact>> {
    let Some(artifact) = value.as_object().and_then(|object| object.get("artifact")) else {
        return Ok(None);
    };
    let values = artifact
        .as_array()
        .ok_or_else(|| eyre!("brew-cask: artifact metadata must be an array"))?;
    let source = values
        .first()
        .and_then(Value::as_str)

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Remove the listed unsupported fields or rename them to allowed ones.
  2. Check the allowed-field set for the specific artifact context (installer vs generate_completions_from_executable).
  3. Verify against the cask definition schema for this parser version.

Example fix

// before
{"manual": "installer/manual/mytool"}  // if manual is not allowed
// after
remove "manual" or use an allowed field
Defensive patterns

Strategy: validation

Validate before calling

fn reject_unknown(o: &serde_json::Map<String, serde_json::Value>, allowed: &[&str]) -> Vec<&String> {
    o.keys().filter(|k| !allowed.contains(&k.as_str())).collect()
}
assert!(reject_unknown(&opts, &["args", "base_name"]).is_empty());

Try / catch

match result {
    Err(e) if e.to_string().contains("unsupported") && e.to_string().contains("field") => {
        // extract field names from message and correct the cask stanza
    }
    other => other?,
}

Prevention

When it happens

Trigger: An `installer` or `generate_completions_from_executable` artifact options object contains a key not in that artifact's allowed set (e.g. typo 'shells' where 'shell' is expected).

Common situations: Typos in option names; copying options between artifact kinds that have different allow-lists; newer Homebrew fields not yet supported by the parser.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/0c2d6f1cf15f162a. Report an issue: GitHub.