pulumi/pulumi · error

'%s' is not a valid project name: %w

Error message

'%s' is not a valid project name: %w

What it means

`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.

Source

Thrown at pkg/cmd/pulumi/project/newcmd/new.go:135

		args.stderr = io.Discard
	}
	if args.selectOne == nil {
		args.selectOne = surveySelect
	}

	// Prepare options.
	opts := display.Options{
		Color:         cmdutil.GetGlobalColorization(),
		IsInteractive: args.interactive,
		Stdout:        args.stdout,
	}

	ssml := cmdStack.NewStackSecretsManagerLoaderFromEnv()
	ws := pkgWorkspace.Instance

	// Validate name (if specified) before further prompts/operations.
	if args.name != "" && pkgWorkspace.ValidateProjectName(args.name) != nil {
		return fmt.Errorf("'%s' is not a valid project name: %w", args.name, pkgWorkspace.ValidateProjectName(args.name))
	}

	// Validate secrets provider type
	if err := cmdStack.ValidateSecretsProvider(args.secretsProvider); err != nil {
		return err
	}

	// Get the current working directory.
	cwd, err := os.Getwd()
	if err != nil {
		return fmt.Errorf("getting the working directory: %w", err)
	}
	originalCwd := cwd

	// If dir was specified, ensure it exists and use it as the
	// current working directory.
	if args.dir != "" {
		cwd, err = UseSpecifiedDir(args.dir)

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Use only lowercase letters, digits, hyphens and underscores; start with a letter or digit
  2. Remove spaces/special characters from --name
  3. Choose a non-reserved name (avoid names like 'pulumi')
  4. If omitted, the template's default name is used — drop the flag if unsure

Example fix

// before
$ pulumi new typescript --name "My Cool Project"
'My Cool Project' is not a valid project name: ...
// after
$ pulumi new typescript --name my-cool-project
Defensive patterns

Strategy: validation

Validate before calling

import re
def valid_name(n):
    return bool(re.fullmatch(r'[a-zA-Z_][a-zA-Z0-9_-]*', n)) and n.lower() != 'pulumi'
assert valid_name(project_name), f"invalid project name: {project_name}"

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/74702f23520341c0. Report an issue: GitHub.