{"record":{"id":"75bca14077c290f1","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-cluster-w","errorCode":null,"errorMessage":"failed to get cluster: %w","messagePattern":"failed to get cluster: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":84,"sourceCode":"\treturn map[string]string{\"status\": \"instance deleted successfully\"}, nil\n}\n\nfunc (s *Source) ListInstances(ctx context.Context) (any, error) {\n\tinstances, err := s.InstanceAdmin.Instances(ctx)\n\tif err != nil {\n\t\tvar partialErr bigtable.ErrPartiallyUnavailable\n\t\tif errors.As(err, &partialErr) {\n\t\t\treturn instances, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to list instances: %w\", err)\n\t}\n\treturn instances, nil\n}\n\nfunc (s *Source) GetCluster(ctx context.Context, instanceId, clusterId string) (any, error) {\n\tcluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get cluster: %w\", err)\n\t}\n\treturn cluster, nil\n}\n\nfunc (s *Source) ListClusters(ctx context.Context, instanceId string) (any, error) {\n\tclusters, err := s.InstanceAdmin.Clusters(ctx, instanceId)\n\tif err != nil {\n\t\tvar partialErr bigtable.ErrPartiallyUnavailable\n\t\tif errors.As(err, &partialErr) {\n\t\t\treturn clusters, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to list clusters: %w\", err)\n\t}\n\treturn clusters, nil\n}\n\nfunc (s *Source) CreateCluster(ctx context.Context, instanceId, clusterId, zone string, numNodes int32) (any, error) {\n\tconf := &bigtable.ClusterConfig{","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L66-L102","documentation":"Raised by GetCluster when the InstanceAdmin.GetCluster admin RPC fails for the requested instance/cluster pair. The wrapped error preserves the underlying cause (NotFound, PermissionDenied, network). It means the specific cluster could not be fetched, most often because it does not exist under the given instance.","triggerScenarios":"Calling GetCluster(ctx, instanceId, clusterId) with a clusterId that does not exist in instanceId (NotFound), a misspelled instance ID, missing bigtable.clusters.get IAM permission, or transient admin API failures.","commonSituations":"Cluster renamed or deleted by another tool/automation; using display name instead of cluster ID; credentials scoped to a service account without Bigtable Admin read roles; wrong project configured so the instance path resolves nowhere.","solutions":["Confirm both IDs via ListInstances/ListClusters or `gcloud bigtable clusters list --instance=INSTANCE`.","Check IAM: ensure the caller has roles/bigtable.admin or bigtable.reader on the project.","Verify the client is bound to the correct project containing the instance.","Inspect the wrapped error code (errors.As / status.FromError); treat NotFound as invalid input, not a retryable fault."],"exampleFix":"// before\ncluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)\n// after\ncluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)\nif err != nil {\n    if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {\n        return nil, fmt.Errorf(\"cluster %q not found in instance %q: %w\", clusterId, instanceId, err)\n    }\n    return nil, fmt.Errorf(\"failed to get cluster: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"// before calling GetCluster\nclusters, err := src.ListClusters(ctx, instanceId)\nif err == nil {\n    found := false\n    for _, c := range clusters.([]*bigtable.ClusterInfo) {\n        if c.Name == clusterId {\n            found = true\n        }\n    }\n    if !found {\n        return fmt.Errorf(\"cluster %q not present in instance %q\", clusterId, instanceId)\n    }\n}","typeGuard":"func isGRPCCode(err error, code codes.Code) bool {\n    if st, ok := status.FromError(errors.Unwrap(err)); ok {\n        return st.Code() == code\n    }\n    return false\n}\n// usage: isGRPCCode(err, codes.NotFound)","tryCatchPattern":"cluster, err := src.GetCluster(ctx, instanceId, clusterId)\nif err != nil {\n    switch {\n    case isGRPCCode(err, codes.NotFound):\n        return fmt.Errorf(\"no cluster %q in instance %q\", clusterId, instanceId)\n    case isGRPCCode(err, codes.PermissionDenied):\n        return fmt.Errorf(\"insufficient IAM permissions for cluster read: %w\", err)\n    default:\n        return err\n    }\n}","preventionTips":["Use cluster IDs (not display names) returned by ListClusters.","Re-list clusters after external automation runs to refresh cached IDs.","Ensure service account has bigtable.clusters.get via roles/bigtable.reader/admin.","Never retry NotFound; classify input errors separately from transient ones."],"tags":["gcp","bigtable","admin-api","get-cluster","error-wrapping"],"backgroundTag":"bigtable-admin-api-error","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"}