{"record":{"id":"55a53b48b79bf46e","repo":"microsoft/aspire","slug":"template","errorCode":null,"errorMessage":"template","messagePattern":"template","errorType":"exception","errorClass":"NonInteractiveException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/NewCommand.cs","lineNumber":325,"sourceCode":"            // The template subcommand was parsed successfully but the template is\n            // not available at runtime (e.g. .NET SDK is not installed).\n            InteractionService.DisplayError($\"Template '{parseResult.CommandResult.Command.Name}' is not available. Ensure the required runtime is installed.\");\n            return null;\n        }\n\n        var templatesForTemplateArgument = GetTemplatesForTemplateArgument(availableTemplates, parseResult);\n        if (templatesForTemplateArgument.Length == 0)\n        {\n            InteractionService.DisplayError(\"No templates are available for the current environment.\");\n            return null;\n        }\n\n        if (!_hostEnvironment.SupportsInteractiveInput)\n        {\n            InteractionService.DisplayError(NewCommandStrings.NonInteractiveTemplateRequired);\n            var templateNames = string.Join(\", \", templatesForTemplateArgument.Select(t => t.Name));\n            InteractionService.DisplaySubtleMessage(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveAvailableValues, templateNames));\n            throw new NonInteractiveException(\"template\");\n        }\n\n        var templatesForPrompt = GetTemplatesForPrompt(availableTemplates, parseResult);\n        if (templatesForPrompt.Length == 0)\n        {\n            InteractionService.DisplayError(\"No templates are available for the current environment.\");\n            return null;\n        }\n\n        var result = await _prompter.PromptForTemplateAsync(templatesForPrompt, cancellationToken);\n\n        return result;\n    }\n\n    private sealed class ResolveTemplateVersionResult\n    {\n        public string? Version { get; init; }\n","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/NewCommand.cs#L307-L343","documentation":"In non-interactive environments, NewCommand cannot prompt for a template. Instead of prompting, it displays the error and available template names and throws NonInteractiveException with the missing argument name 'template'.","triggerScenarios":"Running 'aspire new' (or a template-dependent new command) without --template in an environment where SupportsInteractiveInput is false (CI, non-TTY, piped stdin).","commonSituations":"CI pipelines or scripts running 'aspire new' without the --template flag; running inside a non-interactive shell where prompting is disabled.","solutions":["Pass --template explicitly, e.g. 'aspire new --template aspire-starter'","Run the command in an interactive terminal so the prompt can appear","Pre-provision the project with a script that always supplies --template"],"exampleFix":"// before\naspire new\n// after\naspire new --template aspire-starter -n MyApp","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(template) && !console.IsInputRedirected)\n{\n    template = await PromptForTemplateAsync(); // or fail fast with a clear message\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    exitCode = await aspireNew.RunAsync(...);\n}\ncatch (NonInteractiveException ex) when (ex.Message == \"template\")\n{\n    Console.Error.WriteLine(\"Pass --template <name> when running non-interactively.\");\n    exitCode = 1;\n}","preventionTips":["Always pass --template in CI/non-TTY environments","Detect non-interactive stdin before invoking aspire new","Enumerate available templates once and pin the name in scripts"],"tags":["cli","non-interactive","template"],"backgroundTag":"missing-cli-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}