{"record":{"id":"b1c38203f933cfa3","repo":"kubernetes/kops","slug":"listing-resource-groups-w","errorCode":null,"errorMessage":"listing resource groups: %w","messagePattern":"listing resource groups: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/resourcegroup.go","lineNumber":51,"sourceCode":"\ntype resourceGroupsClientImpl struct {\n\tc *resources.ResourceGroupsClient\n}\n\nvar _ ResourceGroupsClient = (*resourceGroupsClientImpl)(nil)\n\nfunc (c *resourceGroupsClientImpl) CreateOrUpdate(ctx context.Context, name string, parameters resources.ResourceGroup) error {\n\t_, err := c.c.CreateOrUpdate(ctx, name, parameters, nil)\n\treturn err\n}\n\nfunc (c *resourceGroupsClientImpl) List(ctx context.Context) ([]*resources.ResourceGroup, error) {\n\tvar l []*resources.ResourceGroup\n\tpager := c.c.NewListPager(nil)\n\tfor pager.More() {\n\t\tresp, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"listing resource groups: %w\", err)\n\t\t}\n\t\tl = append(l, resp.Value...)\n\t}\n\treturn l, nil\n}\n\nfunc (c *resourceGroupsClientImpl) Delete(ctx context.Context, name string) error {\n\tfuture, err := c.c.BeginDelete(ctx, name, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting resource group: %w\", err)\n\t}\n\tif _, err = future.PollUntilDone(ctx, nil); err != nil {\n\t\treturn fmt.Errorf(\"waiting for resource group deletion completion: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc newResourceGroupsClientImpl(subscriptionID string, cred *azidentity.DefaultAzureCredential) (*resourceGroupsClientImpl, error) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/resourcegroup.go#L33-L69","documentation":"Wraps any pager error while listing all resource groups in the subscription via resources.ResourceGroupsClient.NewListPager. Unlike the public IP lister, there is no ResourceGroupNotFound tolerance, so any NextPage failure — auth, RBAC, throttling, network — surfaces as this error.","triggerScenarios":"resourceGroupsClientImpl.List(ctx) invoked and pager.NextPage(ctx) fails: invalid/expired credentials, identity lacks permission to list resource groups, ARM throttling, or bad subscription ID.","commonSituations":"Stale Azure credentials after token expiry; identity has no Reader at subscription scope; deletion flow polling resource groups while subscription is disabled or misconfigured.","solutions":["Refresh credentials (az login / AZURE_* env vars) and confirm the subscription is active","Grant the identity Reader at subscription scope (Microsoft.Resources/subscriptions/resourceGroups/read)","Read the inner *azcore.ResponseError StatusCode/ErrorCode; retry with backoff on 429/503","Verify the subscription ID used to build the client matches the intended subscription"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"az account show --query id -o tsv   # confirm active subscription before listing\naz role assignment list --assignee $PRINCIPAL --scope /subscriptions/$SUB_ID -o table","typeGuard":"func responseError(err error) (*azcore.ResponseError, bool) {\n  var re *azcore.ResponseError\n  ok := errors.As(err, &re)\n  return re, ok\n}","tryCatchPattern":"groups, err := rgClient.List(ctx)\nif err != nil {\n  if re, ok := responseError(err); ok && (re.StatusCode == 429 || re.StatusCode >= 500) {\n    // retry with backoff\n  }\n  return fmt.Errorf(\"list resource groups: %w\", err)\n}","preventionTips":["Refresh credentials before long-running teardown operations","Grant Reader at subscription scope for listing","Add backoff retry for ARM 429/503 responses","Log ResponseError.StatusCode and ErrorCode, not just the message"],"tags":["azure","resource-groups","pagination","error-wrapping"],"backgroundTag":"azure-sdk-request-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}