{"record":{"id":"3836bea0e97fe1b9","repo":"googleapis/mcp-toolbox","slug":"error-getting-alloydb-instance-w","errorCode":null,"errorMessage":"error getting AlloyDB instance: %w","messagePattern":"error getting AlloyDB instance: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbadmin/alloydbadmin.go","lineNumber":262,"sourceCode":"\tresp, err := service.Projects.Locations.Clusters.Get(urlString).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting AlloyDB cluster: %w\", err)\n\t}\n\n\treturn resp, nil\n}\n\nfunc (s *Source) GetInstance(ctx context.Context, project, location, cluster, instance, 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/instances/%s\", project, location, cluster, instance)\n\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}","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbadmin/alloydbadmin.go#L244-L280","documentation":"This error wraps a failure from the AlloyDB Admin API Instances.Get call, which fetches a single instance under a cluster via its resource path projects/*/locations/*/clusters/*/instances/*. It indicates the REST GET request failed — typically 404, 403, or a transport error. The original API error is wrapped with %w for inspection.","triggerScenarios":"Calling Source.GetInstance with an instance ID that does not exist in the cluster, wrong cluster/location in the path, an access token lacking the required scope, or a network failure during the .Do() call.","commonSituations":"Instance already deleted, typos in instance or cluster names, querying before the create operation finished, expired tokens in long-lived server processes, and regional endpoint misconfiguration.","solutions":["Confirm the instance exists under the cluster (ListInstance or gcloud alloydb instances list)","Verify project/location/cluster/instance IDs are exact and correctly ordered in the resource path","Refresh the access token and check it carries cloud-platform or alloydb.admin scope","Wait for instance creation operations to complete before calling GetInstance","Use errors.As(*googleapi.Error) to distinguish 404 from 403/5xx and act accordingly"],"exampleFix":"// before\nresp, err := service.Projects.Locations.Clusters.Instances.Get(urlString).Do()\nif err != nil { return nil, fmt.Errorf(\"error getting AlloyDB instance: %w\", err) }\n// after\nresp, err := service.Projects.Locations.Clusters.Instances.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(\"instance %s not found in cluster %s: %w\", instance, cluster, err)\n    }\n    return nil, fmt.Errorf(\"error getting AlloyDB instance: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: confirm the parent cluster (and thus instance path) before GetInstance\nif instance == \"\" {\n    return fmt.Errorf(\"instance name is required\")\n}\nif _, err := s.GetCluster(ctx, project, location, cluster, accessToken); err != nil {\n    return fmt.Errorf(\"cluster %s not found; cannot get instance %s: %w\", cluster, instance, err)\n}","typeGuard":"func IsNotFound(err error) bool {\n    var gerr *googleapi.Error\n    return errors.As(err, &gerr) && gerr.Code == 404\n}","tryCatchPattern":"inst, err := s.GetInstance(ctx, project, location, cluster, instance, accessToken)\nif err != nil {\n    var gerr *googleapi.Error\n    if errors.As(err, &gerr) && gerr.Code == 404 {\n        return nil, nil // treat as absent, not fatal\n    }\n    return nil, err\n}","preventionTips":["Only query instances after their create operation reports Done","Validate the full resource path components before the call","Refresh tokens in long-running pollers","Handle 404 as 'absent' rather than retrying"],"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"}