{"record":{"id":"7180ea000389b92f","repo":"clockworklabs/SpacetimeDB","slug":"no-templates-found-for-selected-language","errorCode":null,"errorMessage":"No templates found for selected language","messagePattern":"No templates found for selected language","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":893,"sourceCode":"        })\n        .collect();\n    lang_items.push(\"Clone from GitHub (owner/repo or git URL)\".to_string());\n    lang_items.push(\"None\".to_string());\n\n    let github_clone_index = lang_keys.len();\n    let none_index = lang_keys.len() + 1;\n    loop {\n        let client_selection = FuzzySelect::with_theme(&theme)\n            .with_prompt(\"Select a language (type to filter)\")\n            .items(&lang_items)\n            .default(0)\n            .interact()?;\n\n        if client_selection < lang_keys.len() {\n            let selected_lang = &lang_keys[client_selection];\n            let template_indices = templates_by_lang\n                .get(selected_lang)\n                .ok_or_else(|| anyhow::anyhow!(\"No templates found for selected language\"))?;\n\n            let template = if template_indices.len() > 1 {\n                let template_items: Vec<String> = template_indices\n                    .iter()\n                    .map(|&idx| {\n                        let template = &templates[idx];\n                        format!(\"{} - {}\", template.id, template.description)\n                    })\n                    .collect();\n\n                let pair_prompt = format!(\"Templates available for {selected_lang} (type to filter, Esc to go back)\");\n                let template_selection = FuzzySelect::with_theme(&theme)\n                    .with_prompt(&pair_prompt)\n                    .items(&template_items)\n                    .default(0)\n                    .interact_opt()?;\n\n                let Some(template_selection) = template_selection else {","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/init.rs#L875-L911","documentation":"During fully-interactive `spacetime init`, template metadata is fetched remotely and grouped into a BTreeMap keyed by language label; lang_keys is built directly from that map's keys (init.rs:864). The lookup at init.rs:887 therefore cannot fail under normal construction — this 'No templates found for selected language' error is a defensive guard against state mutation or index/key desynchronization between building the menu and handling the selection.","triggerScenarios":"Selecting a language in the interactive FuzzySelect menu when templates_by_lang no longer contains the selected key — effectively unreachable unless the map is mutated between menu construction (line 848-872) and selection handling, or a CLI bug desynchronizes lang_keys from templates_by_lang.","commonSituations":"Hitting a CLI build where the two collections were built from different template fetches; extremely rare — if reproducible it indicates a bug worth reporting rather than a user misconfiguration.","solutions":["Re-run `spacetime init` — transient inconsistency will not persist across runs","Bypass interactive selection: `spacetime init --template <template-id>` to choose directly","If it reproduces consistently, update the CLI (`spacetime version`) and report the issue with the template list output to SpacetimeDB"],"exampleFix":"# before (interactive, hit the guard)\nspacetime init\n# after (direct template selection)\nspacetime init --template quickstart-csharp","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for i in 1 2 3; do spacetime init --template \"$TEMPLATE_ID\" && break; echo \"attempt $i failed, retrying\"; done","preventionTips":["Prefer non-interactive `spacetime init --template <id>` in automation — it skips the selection menu entirely","Keep the CLI updated so the interactive menu and registry stay in sync","Report reproducible occurrences to SpacetimeDB; this guard indicates an internal invariant break"],"tags":["cli","init","templates","interactive","internal-invariant"],"backgroundTag":"template-selection-failed","analyzedSha":"fdd647dfac506d0967cc4492e9fce380706c94cb","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}