{"record":{"id":"c80d9e7b61a8ebcc","repo":"pulumi/pulumi","slug":"project-name-name-s-and-stack-reference-proje","errorCode":null,"errorMessage":"project name (--name %s) and stack reference project name (--stack %s) must be the same","messagePattern":"project name \\(--name (.+?)\\) and stack reference project name \\(--stack (.+?)\\) must be the same","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/project/newcmd/new.go","lineNumber":896,"sourceCode":"\t\t// No potential for conflicting project names.\n\t\treturn nil\n\t}\n\n\t// Catch the case where the user has specified a fully qualified stack reference.\n\tref, err := b.ParseStackReference(stackName)\n\tif err != nil {\n\t\t// If we can't parse the stack reference, we can't compare the project names.\n\t\t// We assume the project names don't conflict and that this parsing issue will be handled downstream.\n\t\treturn nil\n\t}\n\tstackProjectName, hasProject := ref.Project()\n\tif !hasProject {\n\t\treturn nil\n\t}\n\tif projectName == stackProjectName.String() {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"project name (--name %s) and stack reference project name (--stack %s) must be the same\",\n\t\tprojectName, stackProjectName)\n}\n","sourceCodeStart":878,"sourceCodeEnd":899,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/project/newcmd/new.go#L878-L899","documentation":"`pulumi new` lets you pass both `--name` for the project name and `--stack` as a fully qualified stack reference containing its own project component. The CLI requires the project portion of the stack reference to match `--name`, otherwise the generated project and stack would be inconsistent. It refuses to proceed when they differ.","triggerScenarios":"Running e.g. `pulumi new <template> --name myproj --stack myorg/otherproj/dev` — the project segment of `--stack` (otherproj) does not equal the `--name` value (myproj).","commonSituations":"Copy-pasting an existing stack reference while also setting a custom project name; renaming a project but reusing an old `--stack` value; scripting `pulumi new` with independently sourced name/stack values.","solutions":["Make the project part of `--stack` identical to `--name`, e.g. `--name myproj --stack myorg/myproj/dev`","Drop `--name` and let it default from the stack reference","Drop `--stack` and use `--name` alone, choosing the stack interactively"],"exampleFix":"// before\npulumi new typescript --name myapp --stack myorg/legacy-app/prod\n// after\npulumi new typescript --name myapp --stack myorg/myapp/prod","handlingStrategy":"validation","validationCode":"// Validate before invoking the CLI\nconst stack = \"myorg/myapp/dev\";\nconst name = \"myapp\";\nconst stackProject = stack.split(\"/\")[1];\nif (name !== stackProject) {\n  throw new Error(`--name (${name}) must match project in --stack (${stackProject})`);\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"pulumi\", \"new\", tpl, \"--name\", name, \"--stack\", stack).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"must be the same\") {\n    // fix args: derive name from stack reference\n    parts := strings.Split(stack, \"/\")\n    name = parts[1]\n    // retry with corrected name\n}","preventionTips":["Derive --name from the --stack project segment instead of hardcoding both","Never mix an old stack reference with a renamed project","Assert name/stack consistency in wrapper scripts before calling pulumi"],"tags":["cli","new-command","stack-naming"],"backgroundTag":"mismatched-project-name","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}