{"record":{"id":"0f5800a74c832802","repo":"pulumi/pulumi","slug":"list-policy-groups-failed-w","errorCode":null,"errorMessage":"List Policy Groups failed: %w","messagePattern":"List Policy Groups failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/backend/httpstate/client/client.go","lineNumber":1617,"sourceCode":"\t}\n\n\tvar resp apitype.StartUpdateResponse\n\tif err := pc.restCall(ctx, \"POST\", getUpdatePath(update), nil, req, &resp); err != nil {\n\t\treturn 0, \"\", 0, err\n\t}\n\n\treturn resp.Version, resp.Token, resp.JournalVersion, nil\n}\n\n// ListPolicyGroups lists all `PolicyGroups` the organization has in the Pulumi service.\nfunc (pc *Client) ListPolicyGroups(ctx context.Context, orgName string, inContToken *string) (\n\tapitype.ListPolicyGroupsResponse, *string, error,\n) {\n\t// NOTE: The ListPolicyGroups API on the Pulumi Service is not currently paginated.\n\tvar resp apitype.ListPolicyGroupsResponse\n\terr := pc.restCall(ctx, \"GET\", listPolicyGroupsPath(orgName), nil, nil, &resp)\n\tif err != nil {\n\t\treturn resp, nil, fmt.Errorf(\"List Policy Groups failed: %w\", err)\n\t}\n\treturn resp, nil, nil\n}\n\n// CreatePolicyGroup creates a new Policy Group in the given organization.\nfunc (pc *Client) CreatePolicyGroup(\n\tctx context.Context, orgName string, req apitype.CreatePolicyGroupRequest,\n) error {\n\tif err := pc.restCall(ctx, \"POST\", listPolicyGroupsPath(orgName), nil, req, nil); err != nil {\n\t\treturn fmt.Errorf(\"creating policy group: %w\", err)\n\t}\n\treturn nil\n}\n\n// GetPolicyGroup returns the details of a single Policy Group in the Pulumi\n// service, including the list of Policy Packs applied to it and the stacks or\n// cloud accounts that are members of the group.\nfunc (pc *Client) GetPolicyGroup(","sourceCodeStart":1599,"sourceCodeEnd":1635,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/backend/httpstate/client/client.go#L1599-L1635","documentation":"ListPolicyGroups issues GET against the policy groups endpoint for an organization and wraps any transport or API error as 'List Policy Groups failed: %w'. The note in the source records that this API is not paginated, so the only failure modes are HTTP/decoding errors from restCall (auth, permissions, unknown org, network).","triggerScenarios":"Calling Client.ListPolicyGroups when restCall fails: non-2xx response (401 bad token, 404 unknown orgName, 403 lacking org access) or an undecodable response body.","commonSituations":"Using `pulumi policy ls`/policy CLI workflows with a token lacking access to the organization; a typo'd org name; expired PULUMI_ACCESS_TOKEN; network/proxy issues.","solutions":["Read the wrapped cause (%w) — check for 401/403/404 status and fix auth or org name accordingly","Run `pulumi whoami` to confirm your token is valid and has access to the organization","Verify the organization name exactly matches the Pulumi Service org","Retry after confirming network/proxy connectivity to api.pulumi.com"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"if orgName == \"\" {\n\treturn errors.New(\"organization name is required to list policy groups\")\n}\nif os.Getenv(\"PULUMI_ACCESS_TOKEN\") == \"\" {\n\treturn errors.New(\"PULUMI_ACCESS_TOKEN not set\")\n}","typeGuard":"func isAuthFailure(err error) bool {\n\treturn strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"403\")\n}","tryCatchPattern":"groups, next, err := client.ListPolicyGroups(ctx, orgName)\nif err != nil {\n\tvar retriable = isNetworkError(err) // retry transient network failures\n\tif retriable { return listWithRetry(ctx, orgName, 3) }\n\treturn fmt.Errorf(\"List Policy Groups failed: %w\", err)\n}","preventionTips":["Confirm token validity with `pulumi whoami` before policy operations","Verify org names against `pulumi org` output before API calls","Retry only transient (network/5xx) failures, not 401/403/404","Rotate tokens before expiry in CI environments"],"tags":["policy","api","http"],"backgroundTag":"policy-group-api-failure","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}