{"record":{"id":"505f2118e7229545","repo":"jdx/mise","slug":"brew-cask-generate-completions-from-executable-re-505f21","errorCode":null,"errorMessage":"brew-cask: generate_completions_from_executable requires at least one shell","messagePattern":"brew-cask: generate_completions_from_executable requires at least one shell","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":5427,"sourceCode":"    let shells = options\n        .and_then(|o| o.get(\"shells\"))\n        .and_then(Value::as_array)\n        .map(|shells| {\n            shells\n                .iter()\n                .map(|shell| {\n                    let shell = shell.as_str().ok_or_else(|| {\n                        eyre!(\"brew-cask: completion shell names must be strings\")\n                    })?;\n                    CompletionShell::parse(shell)\n                        .ok_or_else(|| eyre!(\"brew-cask: unsupported completion shell '{shell}'\"))\n                })\n                .collect::<Result<Vec<_>>>()\n        })\n        .transpose()?\n        .unwrap_or_else(|| default_generated_completion_shells(shell_parameter_format.as_deref()));\n    if shells.is_empty() {\n        bail!(\"brew-cask: generate_completions_from_executable requires at least one shell\");\n    }\n    Ok(Some(GeneratedCompletionArtifact {\n        executable,\n        args,\n        base_name: options\n            .and_then(|o| o.get(\"base_name\"))\n            .and_then(Value::as_str)\n            .map(str::to_string),\n        shell_parameter_format,\n        shells,\n    }))\n}\n\nfn default_generated_completion_shells(format: Option<&str>) -> Vec<CompletionShell> {\n    match format {\n        Some(\"cobra\") | Some(\"typer\") => vec![\n            CompletionShell::Bash,\n            CompletionShell::Zsh,","sourceCodeStart":5409,"sourceCodeEnd":5445,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L5409-L5445","documentation":"Thrown at the end of generate_completions_from_executable parsing. If the trailing options object has no 'shells' key, sensible defaults (bash/zsh/fish, plus pwsh for cobra/typer formats) are applied — but an explicitly present 'shells' array that resolves to empty means 'generate completions for zero shells', which is meaningless, so it bails.","triggerScenarios":"{\"generate_completions_from_executable\": [\"mycli\", {\"shells\": []}]} — the shells key exists and is an empty array; defaults are not consulted because the key was explicit.","commonSituations":"Templating that renders shells from an empty variable; users copying a stanza and trimming the list; YAML/JSON pipelines that collapse to empty arrays.","solutions":["Omit the \"shells\" key entirely to get the default shell set","Or list at least one supported shell name, e.g. \"shells\": [\"bash\", \"zsh\", \"fish\", \"pwsh\"]"],"exampleFix":"// before\n{\"generate_completions_from_executable\": [\"mycli\", {\"shells\": []}]}\n// after\n{\"generate_completions_from_executable\": [\"mycli\"]}","handlingStrategy":"validation","validationCode":"fn completions_shells_ok(v: &serde_json::Value) -> bool {\n    let arr = v.get(\"generate_completions_from_executable\").and_then(|a| a.as_array());\n    let Some(arr) = arr else { return true; };\n    let opts = arr.last().and_then(|o| o.as_object());\n    match opts.and_then(|o| o.get(\"shells\")) {\n        Some(serde_json::Value::Array(s)) => !s.is_empty(),\n        None => true,\n        Some(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match parse_generated_completion_artifact(&artifact) {\n    Ok(c) => { /* proceed */ }\n    Err(e) if e.to_string().contains(\"at least one shell\") => {\n        eprintln!(\"omit 'shells' to use defaults, or list bash/zsh/fish/pwsh explicitly\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Remember: defaults apply only when the shells key is ABSENT, not when it is empty","Render shells from a non-empty fallback in templates: shells = list or undefined"],"tags":["brew-cask","mise","completions","config-validation","empty-array"],"backgroundTag":"brew-cask-stanza-validation","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}