jdx/mise · error

mas list --json returned an app object without an ID and…

Error message

mas list --json returned an app object without an ID and version

What it means

When `mas list --json` output is not a single JSON array, the parser falls back to JSON-Lines mode: each line is parsed as an independent JSON value. If any line parses as valid JSON but its object lacks the fields needed to build an InstalledApp (ID and version), this error is raised instead of silently dropping the app.

Solutions

  1. Inspect `mas list --json` output line by line to find the offending object and confirm which fields it has.
  2. Upgrade mas to a version whose JSON lines contain both an app ID and version.
  3. If mas cannot produce the expected schema, pin or replace the mas binary the backend resolves via `configured_toolset_or_path_which`.
Defensive patterns

Strategy: try-catch

Validate before calling

for line in out.lines().filter(|l| !l.is_empty()) {
    let v: serde_json::Value = serde_json::from_str(line)?;
    if v.get("id").is_none() || v.get("version").is_none() { /* handle schema drift before calling backend */ }
}

Type guard

fn line_has_id_and_version(v: &serde_json::Value) -> bool { v.get("id").is_some() && v.get("version").is_some() }

Try / catch

match backend.installed(&pkgs, &opts).await {
    Ok(apps) => apps,
    Err(e) if e.to_string().contains("without an ID and version") => { /* inspect mas output, upgrade mas, retry */ Vec::new() }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: mas_list output where each line is valid JSON (array wrapper absent) but at least one line's object is missing id/version fields, so parse_mas_json_value returns None for that line.

Common situations: mas versions that emit JSON lines with a different object shape; mas emitting status or warning JSON objects interleaved with app objects.

Related errors


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

Appendix: source

Thrown at src/system/packages/mas.rs:115

    }
    if let Ok(Value::Array(values)) = serde_json::from_str::<Value>(output) {
        let apps: Vec<_> = values.iter().filter_map(parse_mas_json_value).collect();
        if apps.is_empty() && !values.is_empty() {
            bail!("mas list --json returned no parseable app objects");
        }
        return Ok(apps);
    }
    let mut apps = vec![];
    for line in output
        .lines()
        .map(str::trim)
        .filter(|line| !line.is_empty())
    {
        let value = serde_json::from_str::<Value>(line)
            .map_err(|err| eyre!("mas list --json returned invalid JSON: {err}"))?;
        match parse_mas_json_value(&value) {
            Some(app) => apps.push(app),
            None => bail!("mas list --json returned an app object without an ID and version"),
        }
    }
    Ok(apps)
}

fn parse_mas_text(output: &str) -> Vec<InstalledApp> {
    output
        .lines()
        .filter_map(|line| {
            let (adam_id, rest) = line.trim().split_once(char::is_whitespace)?;
            if !adam_id.chars().all(|c| c.is_ascii_digit()) {
                return None;
            }
            let version = rest
                .rsplit_once('(')
                .and_then(|(_, v)| v.strip_suffix(')'))
                .unwrap_or("")
                .trim();

View on GitHub (pinned to 533346cc37)