{"record":{"id":"9a4190ea44734c37","repo":"googleapis/mcp-toolbox","slug":"error-getting-alloydb-user-w","errorCode":null,"errorMessage":"error getting AlloyDB user: %w","messagePattern":"error getting AlloyDB user: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbadmin/alloydbadmin.go","lineNumber":277,"sourceCode":"\n\tresp, err := service.Projects.Locations.Clusters.Instances.Get(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting AlloyDB instance: %w\", err)\n\t}\n\treturn resp, nil\n}\n\nfunc (s *Source) GetUsers(ctx context.Context, project, location, cluster, user, 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/users/%s\", project, location, cluster, user)\n\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}","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbadmin/alloydbadmin.go#L259-L295","documentation":"This error wraps a failure from the AlloyDB Admin API Users.Get call, which retrieves a specific user under a cluster via projects/*/locations/*/clusters/*/users/*. It is thrown when the REST GET returns an HTTP error or fails at the transport level. The wrapped error preserves status code and message for the caller.","triggerScenarios":"Calling Source.GetUsers with a user name that does not exist in the cluster, a malformed resource path, an unauthorized/expired access token, or transient network failure during Users.Get(urlString).Do().","commonSituations":"Listing users after a user was deleted, IAM vs built-in user naming confusion (e.g., service account emails), wrong cluster path components, and token scope problems.","solutions":["Verify the user exists (ListUsers) and the exact user ID/email is used","Check project/location/cluster path components are correct","Refresh the access token and confirm it has alloydb scope","Use errors.As(*googleapi.Error) to distinguish 404 (missing user) from 403 (permission) errors","Retry only transient 5xx errors; 404 means the user does not exist"],"exampleFix":"// before\nresp, err := service.Projects.Locations.Clusters.Users.Get(urlString).Do()\nif err != nil { return nil, fmt.Errorf(\"error getting AlloyDB user: %w\", err) }\n// after\nresp, err := service.Projects.Locations.Clusters.Users.Get(urlString).Do()\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) && gerr.Code == 404 {\n        return nil, fmt.Errorf(\"user %s not found in cluster %s: %w\", user, cluster, err)\n    }\n    return nil, fmt.Errorf(\"error getting AlloyDB user: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: verify cluster exists and user name supplied before GetUsers\nif user == \"\" {\n    return fmt.Errorf(\"user name 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 IsNotFound(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && gerr.Code == 404\n}","tryCatchPattern":"u, err := s.GetUsers(ctx, project, location, cluster, userName, accessToken)\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) && gerr.Code == 404 {\n        return nil, fmt.Errorf(\"user %q not found in cluster %q\", userName, cluster)\n    }\n    return nil, err\n}","preventionTips":["Use the exact user ID/email as returned by ListUsers","Keep tokens refreshed in long-lived services","Don't retry 404/403 — only retry 429/5xx","ListUsers first when unsure of the exact user identifier"],"tags":["gcp","alloydb","rest-api","authorization","not-found"],"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"}