{"record":{"id":"6b4356525f79cc31","repo":"googleapis/mcp-toolbox","slug":"error-listing-alloydb-users-w","errorCode":null,"errorMessage":"error listing AlloyDB users: %w","messagePattern":"error listing AlloyDB users: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbadmin/alloydbadmin.go","lineNumber":322,"sourceCode":"\n\tresp, err := service.Projects.Locations.Clusters.Instances.List(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing AlloyDB instances: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) ListUsers(ctx context.Context, project, location, cluster, accessToken string) (any, error) {\n\tservice, err := s.getService(ctx, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\turlString := fmt.Sprintf(\"projects/%s/locations/%s/clusters/%s\", project, location, cluster)\n\n\tresp, err := service.Projects.Locations.Clusters.Users.List(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing AlloyDB users: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) GetOperations(ctx context.Context, project, location, operation, connectionMessageTemplate string, delay time.Duration, accessToken string) (any, error) {\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tservice, err := s.getService(ctx, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tname := fmt.Sprintf(\"projects/%s/locations/%s/operations/%s\", project, location, operation)\n\n\top, err := service.Projects.Locations.Operations.Get(name).Do()","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbadmin/alloydbadmin.go#L304-L340","documentation":"This error wraps a failure from the AlloyDB Admin API Users.List call, which enumerates users under a cluster. It indicates the REST list request returned an HTTP error or failed in transport. The original Google API error remains accessible through the wrapped chain.","triggerScenarios":"Calling Source.ListUsers with a bad cluster resource path, a nonexistent cluster, insufficient token permissions, or a network error during Users.List(urlString).Do().","commonSituations":"Polling users against a deleted cluster, tokens from a different project than the cluster, disabled AlloyDB API, and intermittent network failures.","solutions":["Verify the cluster exists and the path project/location/cluster is correct","Refresh the access token and confirm it has cloud-platform or alloydb.admin scope","Check the AlloyDB Admin API is enabled in the project","Retry transient 5xx/429 errors with backoff","Inspect the wrapped *googleapi.Error to distinguish 404 from 403"],"exampleFix":"// before\nresp, err := service.Projects.Locations.Clusters.Users.List(urlString).Do()\nif err != nil { return nil, fmt.Errorf(\"error listing AlloyDB users: %w\", err) }\n// after\nresp, err := service.Projects.Locations.Clusters.Users.List(urlString).Do()\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) && gerr.Code == 404 {\n        return nil, fmt.Errorf(\"cluster %s not found, cannot list users: %w\", cluster, err)\n    }\n    return nil, fmt.Errorf(\"error listing AlloyDB users: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: validate inputs and cluster existence before ListUsers\nif cluster == \"\" {\n    return fmt.Errorf(\"cluster is required\")\n}\nif _, err := s.GetCluster(ctx, project, location, cluster, accessToken); err != nil {\n    return fmt.Errorf(\"cluster %s not found: %w\", cluster, err)\n}","typeGuard":"func IsPermissionDenied(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && gerr.Code == 403\n}","tryCatchPattern":"users, err := s.ListUsers(ctx, project, location, cluster, accessToken)\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) {\n        if gerr.Code == 403 {\n            return nil, fmt.Errorf(\"missing alloydb.admin permission: %v\", gerr)\n        }\n        if gerr.Code == 429 || gerr.Code >= 500 {\n            return retryWithBackoff(...)\n        }\n    }\n    return nil, err\n}","preventionTips":["Grant the calling service account roles/alloydb.admin","Refresh tokens before administrative batch jobs","Verify cluster exists before listing its users","Only retry transient (429/5xx) failures"],"tags":["gcp","alloydb","rest-api","authorization","network"],"backgroundTag":"gcp-api-request-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}