{"record":{"id":"7f33d47940db73e6","repo":"jdx/mise","slug":"brew-cask-generate-completions-from-executable-re","errorCode":null,"errorMessage":"brew-cask: generate_completions_from_executable requires an executable","messagePattern":"brew-cask: generate_completions_from_executable requires an executable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":5381,"sourceCode":"        }\n        _ => Ok(None),\n    }\n}\n\nfn parse_generated_completion_artifact(\n    value: &Value,\n) -> Result<Option<GeneratedCompletionArtifact>> {\n    let Some(generated) = value\n        .as_object()\n        .and_then(|o| o.get(\"generate_completions_from_executable\"))\n    else {\n        return Ok(None);\n    };\n    let Value::Array(values) = generated else {\n        return Ok(None);\n    };\n    if values.is_empty() {\n        bail!(\"brew-cask: generate_completions_from_executable requires an executable\");\n    }\n    let options = values.last().and_then(Value::as_object);\n    let command_values = if options.is_some() {\n        &values[..values.len() - 1]\n    } else {\n        values.as_slice()\n    };\n    let executable = command_values\n        .first()\n        .and_then(Value::as_str)\n        .ok_or_else(|| {\n            eyre!(\"brew-cask: generate_completions_from_executable requires an executable\")\n        })?\n        .to_string();\n    let args = command_values\n        .iter()\n        .skip(1)\n        .map(|value| {","sourceCodeStart":5363,"sourceCodeEnd":5399,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5363-L5399","documentation":"Thrown while parsing a generate_completions_from_executable artifact. The stanza is an array whose first element must be the executable (string) that generates completions, optionally followed by args and a trailing options object. An empty array provides no executable, so parsing fails immediately; a non-string first element fails the same way via the follow-on lookup.","triggerScenarios":"{\"generate_completions_from_executable\": []} in a cask's artifact list; also an array whose first element is a number/object (e.g. [{\"shell\": \"bash\"}, \"tool\"]) where no string executable can be extracted.","commonSituations":"Templates or generators that emit the stanza with a placeholder that got emptied; cask JSON hand-authored for completion generation; reordering mistakes where the options object is placed first.","solutions":["Make the first array element the executable string: [\"mycli\"] or [\"mycli\", \"completions\", \"--shell\"]","Keep the optional options object (base_name, shells, shell_parameter_format) as the LAST element, never the first","If the cask JSON is upstream and malformed, update mise/brew metadata caches and report the cask token"],"exampleFix":"// before\n{\"generate_completions_from_executable\": []}\n// after\n{\"generate_completions_from_executable\": [\"mycli\", {\"shells\": [\"bash\", \"zsh\"]}]}","handlingStrategy":"validation","validationCode":"fn completions_artifact_ok(v: &serde_json::Value) -> bool {\n    match v.get(\"generate_completions_from_executable\") {\n        Some(serde_json::Value::Array(a)) => a.first().map(|f| f.is_string()).unwrap_or(false),\n        _ => true,\n    }\n}","typeGuard":"fn is_completions_stanza(v: &serde_json::Value) -> bool {\n    matches!(v, serde_json::Value::Array(a) if !a.is_empty() && a[0].is_string())\n}","tryCatchPattern":"match parse_generated_completion_artifact(&artifact) {\n    Ok(c) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"requires an executable\") => {\n        eprintln!(\"completions stanza needs the generator binary as the first array element\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always start the array with the executable string; options object goes last","Omit the stanza entirely for CLI tools without completion support","Never ship empty placeholder arrays from templates"],"tags":["brew-cask","mise","completions","config-validation"],"backgroundTag":"brew-cask-stanza-validation","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}