{"record":{"id":"53d72a8e2897c440","repo":"pulumi/pulumi","slug":"unable-to-lookup-default-org-w","errorCode":null,"errorMessage":"unable to lookup default org: %w","messagePattern":"unable to lookup default org: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/backend/httpstate/stack.go","lineNumber":132,"sourceCode":"\tsnapshot atomic.Pointer[*deploy.Snapshot]\n\t// snapshotStackOutputs contains the stack outputs of the latest deployment snapshot, allocated on first use.\n\t// It's valid for the outputs property map itself to be nil.\n\tsnapshotStackOutputs atomic.Pointer[property.Map]\n\t// b is a pointer to the backend that this stack belongs to.\n\tb *cloudBackend\n\t// tags contains metadata tags describing additional, extensible properties about this stack.\n\ttags map[apitype.StackTagName]string\n\t// escConfigEnv caches if we expect this stack to have its config stored in an ESC environment.\n\tescConfigEnv *string\n}\n\nfunc newStack(ctx context.Context, apistack apitype.Stack, b *cloudBackend) (Stack, error) {\n\tstackName, err := tokens.ParseStackName(apistack.StackName.String())\n\tcontract.AssertNoErrorf(err, \"unexpected invalid stack name: %v\", apistack.StackName)\n\n\tdefaultOrg, err := b.defaultOrg.Result(ctx)\n\tif err != nil {\n\t\treturn &cloudStack{}, fmt.Errorf(\"unable to lookup default org: %w\", err)\n\t}\n\n\tvar escConfigEnv *string\n\tif apistack.Config != nil {\n\t\tescConfigEnv = &apistack.Config.Environment\n\t}\n\n\t// Now assemble all the pieces into a stack structure.\n\treturn &cloudStack{\n\t\tref: cloudBackendReference{\n\t\t\towner:      apistack.OrgName,\n\t\t\tproject:    tokens.Name(apistack.ProjectName),\n\t\t\tdefaultOrg: defaultOrg,\n\t\t\tname:       stackName,\n\t\t\tb:          b,\n\t\t},\n\t\torgName:          apistack.OrgName,\n\t\tcurrentOperation: apistack.CurrentOperation,","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/backend/httpstate/stack.go#L114-L150","documentation":"newStack wraps an error from b.defaultOrg.Result(ctx) — the backend's cached lookup of the user's default organization — when constructing a cloudStack representation from an apitype.Stack. Without the default org the stack object cannot be fully initialized, so GetStack/CreateStack fail. The wrapped cause is typically an API/HTTP error from the service.","triggerScenarios":"Calling GetStack or CreateStack against the Pulumi Cloud backend when the default-org API request fails: invalid or expired API token, network error, or a backend that cannot resolve the caller's default organization.","commonSituations":"Expired or revoked PULUMI_ACCESS_TOKEN; a token for an SSO/identity whose default org can't be determined; the account belonging to no organization; transient 5xx or connectivity failures; behind a corporate proxy blocking the API.","solutions":["Re-authenticate with `pulumi login` (or refresh PULUMI_ACCESS_TOKEN) to fix token problems.","Check connectivity to the Pulumi API endpoint (app.pulumi.com or self-hosted URL) — curl the /api endpoints to verify.","Verify the account has at least one organization or set an explicit default org in the Pulumi Cloud console.","Retry on transient failures; if using a self-hosted backend, verify the service version supports the default-org endpoint."],"exampleFix":"// before\nexport PULUMI_ACCESS_TOKEN=pul- stale-token\n\n// after\npulumi logout && pulumi login   # obtain a fresh token","handlingStrategy":"retry","validationCode":"// preflight: verify the token can resolve the user's orgs\nresp, err := http.Get(cloudURL + \"/api/user\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"pulumi token/org lookup unhealthy (status %d); re-run `pulumi login`\", status(resp))\n}","typeGuard":null,"tryCatchPattern":"stk, err := newStack(ctx, apistack, b)\nif err != nil && strings.Contains(err.Error(), \"unable to lookup default org\") {\n    // transient API/auth issue — back off and retry once\n    time.Sleep(2 * time.Second)\n    stk, err = newStack(ctx, apistack, b)\n}\nif err != nil {\n    return fmt.Errorf(\"stack lookup failed: %w\", err)\n}","preventionTips":["Rotate PULUMI_ACCESS_TOKEN in CI before expiry; prefer OIDC-based short-lived tokens.","Ensure the authenticated identity belongs to at least one organization.","Add retry-with-backoff around cloud API calls in automation.","Allowlist the Pulumi API host in corporate proxies/firewalls."],"tags":["pulumi","cloud-backend","organization","api"],"backgroundTag":"default-org-lookup-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}