{"record":{"id":"6f93ea9345ba6688","repo":"pulumi/pulumi","slug":"resolving-stack-w-6f93ea","errorCode":null,"errorMessage":"resolving stack: %w","messagePattern":"resolving stack: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/stack/stack_drift_list.go","lineNumber":133,"sourceCode":"\tcmd.Flags().IntVar(&dlcmd.count, \"count\", 0,\n\t\t\"Number of results to display (fetches multiple pages if needed)\")\n\tcmd.Flags().BoolVar(&dlcmd.all, \"all\", false,\n\t\t\"Fetch all results (mutually exclusive with --count)\")\n\toutputflag.Var(cmd.Flags(), &dlcmd.output)\n\n\treturn cmd\n}\n\nfunc defaultDriftListClientFactory(\n\tctx context.Context, stackFlag string,\n) (driftListClient, client.StackIdentifier, error) {\n\tws := pkgWorkspace.Instance\n\topts := display.Options{Color: cmdutil.GetGlobalColorization()}\n\n\ts, err := RequireStack(ctx, cmdutil.Diag(), ws, cmdBackend.DefaultLoginManager,\n\t\tstackFlag, LoadOnly, opts, \"\")\n\tif err != nil {\n\t\treturn nil, client.StackIdentifier{}, fmt.Errorf(\"resolving stack: %w\", err)\n\t}\n\n\tcloudStack, ok := s.(httpstate.Stack)\n\tif !ok {\n\t\treturn nil, client.StackIdentifier{},\n\t\t\terrors.New(\"drift commands require the Pulumi Cloud backend; run `pulumi login`\")\n\t}\n\n\tref := cloudStack.Ref()\n\tproject := \"\"\n\tif p, ok := ref.Project(); ok {\n\t\tproject = string(p)\n\t}\n\tstackID := client.StackIdentifier{\n\t\tOwner:   cloudStack.OrgName(),\n\t\tProject: project,\n\t\tStack:   ref.Name(),\n\t}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/stack/stack_drift_list.go#L115-L151","documentation":"Before listing drift runs, the command resolves the target stack via RequireStack (LoadOnly). Any failure from that resolution — unknown stack, wrong project, auth/backend problems, or failure to load the stack — is wrapped with 'resolving stack: %w'. The drift commands need a concrete stack identity to call the Pulumi Cloud drift API.","triggerScenarios":"Running `pulumi stack drift list` when the --stack reference does not match an existing stack; the stack cannot be loaded from the current backend; credentials are expired or the backend is unreachable.","commonSituations":"Typos in the stack name or running from a directory without a Pulumi.yaml project so the fully qualified stack name cannot be derived; being logged into the wrong organization/backend; not logged in at all.","solutions":["Run `pulumi stack ls` to confirm the exact stack name and pass it via --stack.","Run from the project directory (or pass an org/project/stack fully qualified name) so the stack reference resolves.","Re-authenticate with `pulumi login` and check backend connectivity.","Inspect the wrapped cause (the text after 'resolving stack:') for the specific failure and fix accordingly."],"exampleFix":"// before (run outside project dir, ambiguous name)\npulumi stack drift list --stack dev\n// after\npulumi stack drift list --stack my-org/my-project/dev","handlingStrategy":"validation","validationCode":"pulumi stack ls | grep 'my-org/my-project/dev'  # ensure the stack resolves before drift list","typeGuard":null,"tryCatchPattern":"if errText contains \"resolving stack:\" {\n    // fix stack ref / login per wrapped cause, then retry once\n}","preventionTips":["Always pass fully qualified stack names (org/project/stack) in automation.","Run drift commands from the project directory containing Pulumi.yaml.","Check `pulumi whoami` and `pulumi stack ls` before scripted drift queries."],"tags":["cli","stack","backend"],"backgroundTag":"stack-not-found","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}