{"record":{"id":"4d5dc190e017a982","repo":"astrid-runtime/astrid","slug":"group-group-name-has-no-capsules","errorCode":null,"errorMessage":"group '{group_name}' has no capsules","messagePattern":"group '(.+?)' has no capsules","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/init.rs","lineNumber":431,"sourceCode":"    // fallback; iterate groups in sorted order for stable warnings.\n    let mut groups: HashMap<String, Vec<DistroCapsule>> = HashMap::new();\n    for cap in capsules {\n        match &cap.group {\n            None => selected.push(cap),\n            Some(group) => groups.entry(group.clone()).or_default().push(cap),\n        }\n    }\n\n    let mut group_names: Vec<String> = groups.keys().cloned().collect();\n    group_names.sort_unstable();\n    for group_name in group_names {\n        let group_caps = groups.remove(&group_name).unwrap_or_default();\n        let defaults: Vec<DistroCapsule> =\n            group_caps.iter().filter(|c| c.default).cloned().collect();\n        if defaults.is_empty() {\n            let first = group_caps\n                .first()\n                .ok_or_else(|| anyhow::anyhow!(\"group '{group_name}' has no capsules\"))?;\n            eprintln!(\n                \"{}\",\n                Theme::warning(&format!(\n                    \"group '{group_name}' has no default capsule — selecting first: {}\",\n                    first.name\n                ))\n            );\n            selected.push(first.clone());\n        } else {\n            selected.extend(defaults);\n        }\n    }\n\n    Ok(selected)\n}\n\n/// Prompt for distro-level variables needed by the selected capsules.\n/// Only prompts for variables that are actually referenced by a selected capsule's env.","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/init.rs#L413-L449","documentation":"In headless (non-interactive) capsule selection, after filtering a group's capsules for `default: true`, the code needs a fallback first capsule. If the group contains no capsules at all, both defaults and the first-item fallback are unavailable, so this error is thrown naming the empty group.","triggerScenarios":"Running `astrid init` in headless mode (e.g. in CI) where the requested --group names a group with zero capsules in the distribution manifest, or where group name resolution produced an empty bucket.","commonSituations":"Typo in the group name (a group key doesn't exist, so remove(&group_name).unwrap_or_default() silently yields an empty vec); distribution manifest updated and the group was removed or renamed; CI scripts pinned to stale group names.","solutions":["Check the group name spelling against the available groups listed by init","Update the group name to one that exists in the current distribution manifest","If authoring the manifest, add capsules to the group","Make the error list valid group names to speed up diagnosis"],"exampleFix":"// before\n.ok_or_else(|| anyhow::anyhow!(\"group '{group_name}' has no capsules\"))?;\n// after\n.ok_or_else(|| anyhow::anyhow!(\n    \"group '{group_name}' has no capsules (known groups: {}) — check --group spelling\",\n    groups.keys().cloned().collect::<Vec<_>>().join(\", \")\n))?;","handlingStrategy":"validation","validationCode":"// preflight: confirm the group exists and is non-empty before headless init\nlet group_ok = manifest.groups.iter()\n    .any(|g| g.name == requested_group && !g.capsules.is_empty());\nif !group_ok {\n    bail!(\"group '{}' missing or empty; available: {:?}\", requested_group,\n          manifest.groups.iter().map(|g| &g.name).collect::<Vec<_>>());\n}","typeGuard":null,"tryCatchPattern":"match select_capsules(&groups, &group_name, /*headless=*/ true) {\n    Err(e) if e.to_string().contains(\"has no capsules\") => {\n        eprintln!(\"{e}; falling back to default group\");\n        select_capsules(&groups, DEFAULT_GROUP, true)?\n    }\n    other => other?,\n}","preventionTips":["Verify group names against the current manifest before headless runs","Keep at least one capsule per group in the distribution manifest","Avoid unwrap_or_default when looking up group buckets — surface unknown group names","Pin CI to explicit, tested group names"],"tags":["cli","headless","configuration","capsules"],"backgroundTag":"resource-not-found","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}