{"record":{"id":"bac2be129a3b3fc7","repo":"jdx/mise","slug":"mas-list-json-returned-no-parseable-app-objects","errorCode":null,"errorMessage":"mas list --json returned no parseable app objects","messagePattern":"mas list --json returned no parseable app objects","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/mas.rs","lineNumber":101,"sourceCode":"            \"versionString\",\n        ],\n    )?;\n    Some(InstalledApp {\n        adam_id,\n        bundle_id,\n        version,\n    })\n}\n\nfn parse_mas_json(output: &str) -> EyreResult<Vec<InstalledApp>> {\n    let output = output.trim();\n    if output.is_empty() {\n        return Ok(vec![]);\n    }\n    if let Ok(Value::Array(values)) = serde_json::from_str::<Value>(output) {\n        let apps: Vec<_> = values.iter().filter_map(parse_mas_json_value).collect();\n        if apps.is_empty() && !values.is_empty() {\n            bail!(\"mas list --json returned no parseable app objects\");\n        }\n        return Ok(apps);\n    }\n    let mut apps = vec![];\n    for line in output\n        .lines()\n        .map(str::trim)\n        .filter(|line| !line.is_empty())\n    {\n        let value = serde_json::from_str::<Value>(line)\n            .map_err(|err| eyre!(\"mas list --json returned invalid JSON: {err}\"))?;\n        match parse_mas_json_value(&value) {\n            Some(app) => apps.push(app),\n            None => bail!(\"mas list --json returned an app object without an ID and version\"),\n        }\n    }\n    Ok(apps)\n}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/mas.rs#L83-L119","documentation":"`parse_mas_json` parses the output of `mas list --json`. If the whole output parses as a JSON array but none of its elements yield an app (ID and version), and the array was non-empty, the backend raises this error rather than returning an empty install list. It guards against silently treating malformed mas output as \"nothing installed\".","triggerScenarios":"Calling mas_list (e.g. via the installed() query) where `mas list --json` prints a valid JSON array whose objects are missing the fields parse_mas_json_value requires (numeric/parseable id and version), so every element maps to None.","commonSituations":"A newer or older mas version changed the JSON schema of `mas list --json` (field renames like `adam_id` vs `id`); mas emitting error/placeholder JSON objects on an oddly configured system.","solutions":["Check `mas version` and upgrade/downgrade mas so its `list --json` output matches the expected schema (objects with ID and version fields).","Run `mas list --json` manually and inspect the raw JSON to see which fields the objects actually contain.","Fall back to text output by checking whether a non-JSON mas is installed or the CLI supports --json at all."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let out = Command::new(\"mas\").args([\"list\", \"--json\"]).output()?;\nlet v: serde_json::Value = serde_json::from_slice(&out.stdout)?;\nif let Value::Array(arr) = &v {\n    let ok = arr.iter().all(|o| o.get(\"id\").is_some() && o.get(\"version\").is_some());\n    if !ok { /* upgrade mas or fall back to text parsing */ }\n}","typeGuard":"fn looks_like_mas_app(v: &serde_json::Value) -> bool { v.get(\"id\").is_some() && v.get(\"version\").is_some() }","tryCatchPattern":"match backend.installed(&pkgs, &opts).await {\n    Ok(apps) => apps,\n    Err(e) if e.to_string().contains(\"no parseable app objects\") => { /* upgrade mas, then retry */ Vec::new() }\n    Err(e) => return Err(e),\n}","preventionTips":["Pin a mas version known to emit the expected `mas list --json` schema.","Sanity-check mas JSON output after upgrading mas.","Watch mas release notes for `list --json` schema changes."],"tags":["mas","json","parse","schema"],"backgroundTag":"unexpected-response-shape","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"}