{"record":{"id":"07cae9278cad22e3","repo":"pulumi/pulumi","slug":"only-one-of-stack-or-argument-stack-name-may-be-07cae9","errorCode":null,"errorMessage":"only one of --stack or argument stack name may be specified, not both","messagePattern":"only one of --stack or argument stack name may be specified, not both","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/stack/stack_select.go","lineNumber":69,"sourceCode":"\t\t\tws := pkgWorkspace.Instance\n\t\t\topts := display.Options{\n\t\t\t\tColor: cmdutil.GetGlobalColorization(),\n\t\t\t}\n\n\t\t\t// Try to read the current project\n\t\t\tproject, root, err := ws.ReadProject(\"\")\n\t\t\tif err != nil && !errors.Is(err, workspace.ErrProjectNotFound) {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tb, err := backend.CurrentBackend(ctx, ws, backend.DefaultLoginManager, project, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif len(args) > 0 {\n\t\t\t\tif stack != \"\" {\n\t\t\t\t\treturn errors.New(\"only one of --stack or argument stack name may be specified, not both\")\n\t\t\t\t}\n\n\t\t\t\tstack = args[0]\n\t\t\t}\n\n\t\t\tif stack == \"\" && !cmdutil.Interactive() {\n\t\t\t\treturn backenderr.NoStackSelectedError{}\n\t\t\t}\n\n\t\t\tif stack != \"\" {\n\t\t\t\t// A stack was given, ask the backend about it.\n\t\t\t\tstackRef, stackErr := b.ParseStackReference(stack)\n\t\t\t\tif stackErr != nil {\n\t\t\t\t\treturn stackErr\n\t\t\t\t}\n\n\t\t\t\ts, stackErr := b.GetStack(ctx, stackRef)\n\t\t\t\tif stackErr != nil {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/stack/stack_select.go#L51-L87","documentation":"Validation error in `pulumi stack select`: the stack name was supplied twice — once via the --stack flag and once as a positional argument. The CLI refuses ambiguity rather than guessing which source wins.","triggerScenarios":"Running e.g. `pulumi stack select -s prod prod` or `pulumi stack select my-stack --stack my-stack`. Any case where len(args) > 0 and the stack flag is non-empty triggers it.","commonSituations":"Scripts that append a stack name while also setting --stack; muscle memory mixing `pulumi stack select <name>` with the --stack convention from other commands.","solutions":["Supply the stack name only once — either as the argument or via --stack, not both","Remove the redundant --stack flag if the positional name is intended","Fix the wrapping script so it passes exactly one of the two"],"exampleFix":"// before\npulumi stack select --stack prod prod\n// after\npulumi stack select prod","handlingStrategy":"validation","validationCode":"if [[ -n \"$STACK_FLAG\" && -n \"$STACK_ARG\" ]]; then echo \"pass only one of --stack or positional stack name\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one convention (positional name) for stack select in scripts","Do not append stack names to commands that already set --stack","Lint wrapper scripts for duplicated stack arguments"],"tags":["cli","validation","stacks"],"backgroundTag":"conflicting-arguments","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}