{"record":{"id":"74702f23520341c0","repo":"pulumi/pulumi","slug":"s-is-not-a-valid-project-name-w-74702f","errorCode":null,"errorMessage":"'%s' is not a valid project name: %w","messagePattern":"'(.+?)' is not a valid project name: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/project/newcmd/new.go","lineNumber":135,"sourceCode":"\t\targs.stderr = io.Discard\n\t}\n\tif args.selectOne == nil {\n\t\targs.selectOne = surveySelect\n\t}\n\n\t// Prepare options.\n\topts := display.Options{\n\t\tColor:         cmdutil.GetGlobalColorization(),\n\t\tIsInteractive: args.interactive,\n\t\tStdout:        args.stdout,\n\t}\n\n\tssml := cmdStack.NewStackSecretsManagerLoaderFromEnv()\n\tws := pkgWorkspace.Instance\n\n\t// Validate name (if specified) before further prompts/operations.\n\tif args.name != \"\" && pkgWorkspace.ValidateProjectName(args.name) != nil {\n\t\treturn fmt.Errorf(\"'%s' is not a valid project name: %w\", args.name, pkgWorkspace.ValidateProjectName(args.name))\n\t}\n\n\t// Validate secrets provider type\n\tif err := cmdStack.ValidateSecretsProvider(args.secretsProvider); err != nil {\n\t\treturn err\n\t}\n\n\t// Get the current working directory.\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting the working directory: %w\", err)\n\t}\n\toriginalCwd := cwd\n\n\t// If dir was specified, ensure it exists and use it as the\n\t// current working directory.\n\tif args.dir != \"\" {\n\t\tcwd, err = UseSpecifiedDir(args.dir)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/project/newcmd/new.go#L117-L153","documentation":"`pulumi new --name <name>` validates the project name against Pulumi's naming rules (must be a valid identifier: alphanumerics, hyphens, underscores, starting with a letter/digit, etc.). An invalid name is rejected with this error wrapping the specific validation failure.","triggerScenarios":"`pulumi new <template> --name <invalid>` where pkgWorkspace.ValidateProjectName fails: name starts with a digit... actually disallowed leading/trailing hyphens, uppercase letters, spaces, special characters, reserved words like 'pulumi', or empty segments.","commonSituations":"Copy-pasting a project title (e.g. 'My Cool Project!') into --name; using spaces or uppercase; using names with leading digits was historically rejected; shell interpolation producing empty --name.","solutions":["Use only lowercase letters, digits, hyphens and underscores; start with a letter or digit","Remove spaces/special characters from --name","Choose a non-reserved name (avoid names like 'pulumi')","If omitted, the template's default name is used — drop the flag if unsure"],"exampleFix":"// before\n$ pulumi new typescript --name \"My Cool Project\"\n'My Cool Project' is not a valid project name: ...\n// after\n$ pulumi new typescript --name my-cool-project","handlingStrategy":"validation","validationCode":"import re\ndef valid_name(n):\n    return bool(re.fullmatch(r'[a-zA-Z_][a-zA-Z0-9_-]*', n)) and n.lower() != 'pulumi'\nassert valid_name(project_name), f\"invalid project name: {project_name}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use kebab-case names without spaces or special characters","Validate the name in CI before invoking pulumi new","Let the template default the name when unsure"],"tags":["cli","validation","naming"],"backgroundTag":"invalid-project-name","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}