pulumi/pulumi · error

missing stack name

Error message

missing stack name

What it means

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.

Source

Thrown at sdk/go/pulumi/run.go:87

}

func runErrInner(body RunFunc, logError func(*Context, error), opts ...RunOption) error {
	// Parse the info out of environment variables.  This is a lame contract with the caller, but helps to keep
	// boilerplate to a minimum in the average Pulumi Go program.
	info := getEnvInfo()
	if info.getPlugins {
		return ErrPlugins
	}

	for _, o := range opts {
		o(&info)
	}

	// Validate some properties.
	if info.Project == "" {
		return errors.New("missing project name")
	} else if info.Stack == "" {
		return errors.New("missing stack name")
	} else if info.MonitorAddr == "" && info.Mocks == nil {
		return errors.New("missing resource monitor RPC address")
	} else if info.EngineAddr == "" && info.Mocks == nil {
		return errors.New("missing engine RPC address")
	}

	ctx := initTracing(context.TODO())
	defer shutdownTracing()

	// Create a fresh context.
	pctx, err := NewContext(ctx, info)
	if err != nil {
		return err
	}
	defer contract.IgnoreClose(pctx)

	err = RunWithContext(pctx, body)
	// Log the error message

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Run via `pulumi up` so the CLI passes the stack name.
  2. Pass pulumi.Stack("<name>") as a RunOption.
  3. In embedded/automation scenarios, set PULUMI_STACK_NAME or info.Stack before Run.

Example fix

// before
pulumi.Run(fn) // no stack
// after
pulumi.Run(fn, pulumi.Stack("dev"))
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("PULUMI_STACK_NAME") == "" && stackOptionAbsent {
    // will fail: supply pulumi.Stack("name") before Run
}

Prevention

When it happens

Trigger: Calling pulumi.Run without pulumi.Stack(...) and without the Pulumi CLI supplying PULUMI_STACK_NAME; constructing RunInfo manually with an empty Stack.

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

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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