{"record":{"id":"9ff6e640892ca4db","repo":"googleapis/mcp-toolbox","slug":"error-listing-alloydb-clusters-w","errorCode":null,"errorMessage":"error listing AlloyDB clusters: %w","messagePattern":"error listing AlloyDB clusters: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbadmin/alloydbadmin.go","lineNumber":292,"sourceCode":"\n\tresp, err := service.Projects.Locations.Clusters.Users.Get(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting AlloyDB user: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) ListCluster(ctx context.Context, project, location, 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\", project, location)\n\n\tresp, err := service.Projects.Locations.Clusters.List(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing AlloyDB clusters: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) ListInstance(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.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}","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbadmin/alloydbadmin.go#L274-L310","documentation":"This error wraps a failure from the AlloyDB Admin API Clusters.List call, which enumerates all clusters in a given project and location. It fires when the REST list request returns an HTTP error or transport failure. The underlying Google API error is preserved via %w so status codes can be examined.","triggerScenarios":"Calling Source.ListCluster with a nonexistent or misspelled location (e.g., wrong region), an expired/under-scoped access token, or network failure during Projects.Locations.Clusters.List(urlString).Do().","commonSituations":"Configured region not matching where clusters were provisioned, disabled AlloyDB Admin API in the project, quota or rate-limit responses (429), and stale tokens in services without token refresh.","solutions":["Verify the location is a valid AlloyDB region and the project ID is correct","Ensure the AlloyDB Admin API (alloydb.googleapis.com) is enabled on the project","Refresh the access token and check it has cloud-platform or alloydb.admin scope","Retry on 429/5xx with exponential backoff","Inspect the wrapped *googleapi.Error for the exact HTTP status and message"],"exampleFix":"// before\nresp, err := service.Projects.Locations.Clusters.List(urlString).Do()\nif err != nil { return nil, fmt.Errorf(\"error listing AlloyDB clusters: %w\", err) }\n// after\nresp, err := service.Projects.Locations.Clusters.List(urlString).Do()\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) {\n        if gerr.Code == 403 && strings.Contains(gerr.Message, \"has not been used\") {\n            return nil, fmt.Errorf(\"enable the AlloyDB Admin API on project %s: %w\", project, err)\n        }\n    }\n    return nil, fmt.Errorf(\"error listing AlloyDB clusters: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// Go: validate location/project and token presence before ListCluster\nif project == \"\" || location == \"\" {\n    return fmt.Errorf(\"project and location must be non-empty\")\n}\nif accessToken == \"\" {\n    return fmt.Errorf(\"access token missing; obtain one with cloud-platform scope\")\n}","typeGuard":"func IsRetryable(err error) bool {\n    var gerr *googleapi.Error\n    if !errors.As(err, &gerr) {\n        return true // transport errors are usually retryable\n    }\n    return gerr.Code == 429 || gerr.Code >= 500\n}","tryCatchPattern":"var resp any\nerr := retry.Do(3, func() error {\n    var e error\n    resp, e = s.ListCluster(ctx, project, location, accessToken)\n    var gerr *googleapi.Error\n    if errors.As(e, &gerr) && (gerr.Code == 429 || gerr.Code >= 500) {\n        return e // retry\n    }\n    return retry.Stop(e) // no retry\n})","preventionTips":["Enable the AlloyDB Admin API before first use","Refresh tokens on a schedule, not on-demand after expiry","Use valid AlloyDB region names from configuration validated at boot","Apply exponential backoff for 429/5xx list calls"],"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"}