{"record":{"id":"f7e7c33840d7f228","repo":"fullstackhero/dotnet-starter-kit","slug":"project-name-is-required-in-non-interactive-mode-pass-it-as","errorCode":null,"errorMessage":"Project name is required in non-interactive mode. Pass it as: fsh new <name>","messagePattern":"Project name is required in non-interactive mode\\. Pass it as: fsh new <name>","errorType":"console","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Tools/CLI/Commands/NewCommand.cs","lineNumber":149,"sourceCode":"        // 10. Print next steps\n        PrintNextSteps(name, aspire, frontend, settings.SkipInstall, dockerEnvReady);\n\n        return 0;\n    }\n\n    private static void PrintBanner()\n    {\n        AnsiConsole.Write(new FigletText(\"fsh\").Color(Color.DodgerBlue1));\n        AnsiConsole.MarkupLine(\"[bold]FullStackHero .NET Starter Kit[/]\");\n        AnsiConsole.WriteLine();\n    }\n\n    private static async Task<string> ResolveNameAsync(Settings settings, CancellationToken cancellationToken)\n    {\n        if (settings.Name is not null) return settings.Name;\n\n        if (settings.NonInteractive)\n            throw new InvalidOperationException(\"Project name is required in non-interactive mode. Pass it as: fsh new <name>\");\n\n        return await new TextPrompt<string>($\"[{FshConstants.AccentColor}]Project name:[/]\")\n            .Validate(input =>\n            {\n                string? error = ProjectNameValidator.Validate(input);\n                return error is null\n                    ? ValidationResult.Success()\n                    : ValidationResult.Error(error);\n            })\n            .ShowAsync(AnsiConsole.Console, cancellationToken).ConfigureAwait(false);\n    }\n\n    private static async Task<bool> ResolveAspireAsync(Settings settings, CancellationToken cancellationToken)\n    {\n        if (settings.NoAspire) return false;\n        if (settings.NonInteractive) return true;\n\n        return await new ConfirmationPrompt($\"[{FshConstants.AccentColor}]Include .NET Aspire AppHost?[/]\")","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/fullstackhero/dotnet-starter-kit/blob/3f2959e683e9f83f13e55e1678c9119f63c7e8e5/src/Tools/CLI/Commands/NewCommand.cs#L131-L167","documentation":"The `fsh new` CLI command requires a project name. When running with --non-interactive (CI/scripted usage) and no name was supplied via `fsh new <name>` or settings, ResolveNameAsync throws InvalidOperationException because it cannot fall back to an interactive TextPrompt.","triggerScenarios":"Running `fsh new --non-interactive` (or a non-TTY environment where interactivity is disabled) without a positional name argument; a settings file/pipeline that omits Name while non-interactive mode is on; invoking the command from a script or CI job with missing arguments.","commonSituations":"CI pipelines (GitHub Actions, Docker builds) without a TTY that force non-interactive mode; scripts copied from a colleague that dropped the name argument; documentation examples omitting that non-interactive mode requires the positional name.","solutions":["Pass the project name positionally: `fsh new MyProject --non-interactive`.","Set the project name in the CLI settings/input the command reads (settings.Name) so ResolveNameAsync short-circuits before the check.","Remove --non-interactive when running in an interactive terminal so the TextPrompt can ask for the name.","In CI, supply the name via an env/variable interpolated into the command line, e.g. `fsh new $PROJECT_NAME --non-interactive`."],"exampleFix":"// before (CI step)\n- run: fsh new --non-interactive\n// after\n- run: fsh new ${{ inputs.projectName }} --non-interactive","handlingStrategy":"validation","validationCode":"// shell pre-check\nif [ -z \"$PROJECT_NAME\" ]; then echo 'PROJECT_NAME is required with --non-interactive'; exit 1; fi\nfsh new \"$PROJECT_NAME\" --non-interactive","typeGuard":null,"tryCatchPattern":"try {\n  await run('fsh', ['new', '--non-interactive']);\n} catch (e) {\n  if (String(e).includes('Project name is required')) {\n    throw new Error('Add a positional name: fsh new <name> --non-interactive');\n  } throw e;\n}","preventionTips":["In CI, always pass the positional name to `fsh new`.","Only use --non-interactive in scripts; rely on prompts locally.","Add a wrapper script that asserts the name argument exists before invoking the CLI."],"tags":["cli","validation","non-interactive","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"3f2959e683e9f83f13e55e1678c9119f63c7e8e5","analyzedAt":"2026-09-15T22:20:53.684Z","contentChangedAt":"2026-09-15T22:20:53.684Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}