googleapis/mcp-toolbox · error
failed to get cluster: %w
Error message
failed to get cluster: %w
What it means
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.
Source
Thrown at internal/sources/bigtable/admin_wrappers.go:84
return map[string]string{"status": "instance deleted successfully"}, nil
}
func (s *Source) ListInstances(ctx context.Context) (any, error) {
instances, err := s.InstanceAdmin.Instances(ctx)
if err != nil {
var partialErr bigtable.ErrPartiallyUnavailable
if errors.As(err, &partialErr) {
return instances, nil
}
return nil, fmt.Errorf("failed to list instances: %w", err)
}
return instances, nil
}
func (s *Source) GetCluster(ctx context.Context, instanceId, clusterId string) (any, error) {
cluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)
if err != nil {
return nil, fmt.Errorf("failed to get cluster: %w", err)
}
return cluster, nil
}
func (s *Source) ListClusters(ctx context.Context, instanceId string) (any, error) {
clusters, err := s.InstanceAdmin.Clusters(ctx, instanceId)
if err != nil {
var partialErr bigtable.ErrPartiallyUnavailable
if errors.As(err, &partialErr) {
return clusters, nil
}
return nil, fmt.Errorf("failed to list clusters: %w", err)
}
return clusters, nil
}
func (s *Source) CreateCluster(ctx context.Context, instanceId, clusterId, zone string, numNodes int32) (any, error) {
conf := &bigtable.ClusterConfig{View on GitHub (pinned to 8cc6e09de2)
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.
Example fix
// before
cluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)
// after
cluster, err := s.InstanceAdmin.GetCluster(ctx, instanceId, clusterId)
if err != nil {
if st, ok := status.FromError(err); ok && st.Code() == codes.NotFound {
return nil, fmt.Errorf("cluster %q not found in instance %q: %w", clusterId, instanceId, err)
}
return nil, fmt.Errorf("failed to get cluster: %w", err)
} Defensive patterns
Strategy: type-guard
Validate before calling
// before calling GetCluster
clusters, err := src.ListClusters(ctx, instanceId)
if err == nil {
found := false
for _, c := range clusters.([]*bigtable.ClusterInfo) {
if c.Name == clusterId {
found = true
}
}
if !found {
return fmt.Errorf("cluster %q not present in instance %q", clusterId, instanceId)
}
} Type guard
func isGRPCCode(err error, code codes.Code) bool {
if st, ok := status.FromError(errors.Unwrap(err)); ok {
return st.Code() == code
}
return false
}
// usage: isGRPCCode(err, codes.NotFound) Try / catch
cluster, err := src.GetCluster(ctx, instanceId, clusterId)
if err != nil {
switch {
case isGRPCCode(err, codes.NotFound):
return fmt.Errorf("no cluster %q in instance %q", clusterId, instanceId)
case isGRPCCode(err, codes.PermissionDenied):
return fmt.Errorf("insufficient IAM permissions for cluster read: %w", err)
default:
return err
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to delete instance: %w
- failed to list instances: %w
- failed to list clusters: %w
- failed to create cluster: %w
- failed to update cluster: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/75bca14077c290f1.
Report an issue: GitHub.