{"record":{"id":"930b1d7ac52df8e4","repo":"pulumi/pulumi","slug":"missing-stack-name-930b1d","errorCode":null,"errorMessage":"missing stack name","messagePattern":"missing stack name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/pulumi/run.go","lineNumber":87,"sourceCode":"}\n\nfunc runErrInner(body RunFunc, logError func(*Context, error), opts ...RunOption) error {\n\t// Parse the info out of environment variables.  This is a lame contract with the caller, but helps to keep\n\t// boilerplate to a minimum in the average Pulumi Go program.\n\tinfo := getEnvInfo()\n\tif info.getPlugins {\n\t\treturn ErrPlugins\n\t}\n\n\tfor _, o := range opts {\n\t\to(&info)\n\t}\n\n\t// Validate some properties.\n\tif info.Project == \"\" {\n\t\treturn errors.New(\"missing project name\")\n\t} else if info.Stack == \"\" {\n\t\treturn errors.New(\"missing stack name\")\n\t} else if info.MonitorAddr == \"\" && info.Mocks == nil {\n\t\treturn errors.New(\"missing resource monitor RPC address\")\n\t} else if info.EngineAddr == \"\" && info.Mocks == nil {\n\t\treturn errors.New(\"missing engine RPC address\")\n\t}\n\n\tctx := initTracing(context.TODO())\n\tdefer shutdownTracing()\n\n\t// Create a fresh context.\n\tpctx, err := NewContext(ctx, info)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer contract.IgnoreClose(pctx)\n\n\terr = RunWithContext(pctx, body)\n\t// Log the error message","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/pulumi/run.go#L69-L105","documentation":"Companion validation to the project check: RunInfo.Stack must be non-empty. The stack identifies the deployment target and is required for engine communication, so Run returns this error when it is unset and not supplied by options.","triggerScenarios":"Calling pulumi.Run without pulumi.Stack(...) and without the Pulumi CLI supplying PULUMI_STACK_NAME; constructing RunInfo manually with an empty Stack.","commonSituations":"go run main.go outside the Pulumi CLI with no stack env vars; custom automation harness forgetting to set the stack; local test scaffolding for a Pulumi program.","solutions":["Run via `pulumi up` so the CLI passes the stack name.","Pass pulumi.Stack(\"<name>\") as a RunOption.","In embedded/automation scenarios, set PULUMI_STACK_NAME or info.Stack before Run."],"exampleFix":"// before\npulumi.Run(fn) // no stack\n// after\npulumi.Run(fn, pulumi.Stack(\"dev\"))","handlingStrategy":"validation","validationCode":"if os.Getenv(\"PULUMI_STACK_NAME\") == \"\" && stackOptionAbsent {\n    // will fail: supply pulumi.Stack(\"name\") before Run\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass pulumi.Stack(...) in custom main() functions.","Run via `pulumi up` with a selected stack (pulumi stack select).","Verify PULUMI_STACK_NAME propagation in automation harnesses."],"tags":["go","configuration","program-setup"],"backgroundTag":"missing-env-var","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}