googleapis/mcp-toolbox · error
failed to get cluster: %w
Error message
failed to get cluster: %w
What it means
Thrown by the Dataproc source's GetCluster when client.GetCluster returns an error from the ClusterController GetCluster RPC. The wrapped error preserves the GCP API status (not found, permission denied, region mismatch, etc.).
Source
Thrown at internal/sources/dataproc/dataproc.go:234
}
clusters = append(clusters, cluster)
}
return clusters, nil
}
// GetCluster gets a single cluster.
func (s *Source) GetCluster(ctx context.Context, clusterName string) (any, error) {
client := s.GetClusterControllerClient()
req := &dataprocpb.GetClusterRequest{
ProjectId: s.Project,
Region: s.Region,
ClusterName: clusterName,
}
clusterPb, err := client.GetCluster(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get cluster: %w", err)
}
jsonBytes, err := protojson.Marshal(clusterPb)
if err != nil {
return nil, fmt.Errorf("failed to marshal cluster to JSON: %w", err)
}
var result map[string]any
if err := json.Unmarshal(jsonBytes, &result); err != nil {
return nil, fmt.Errorf("failed to unmarshal cluster JSON: %w", err)
}
consoleUrl := ClusterConsoleURLFromProto(clusterPb, s.Region)
logsUrl := ClusterLogsURLFromProto(clusterPb, s.Region)
wrappedResult := map[string]any{
"consoleUrl": consoleUrl,
"logsUrl": logsUrl,View on GitHub (pinned to 8cc6e09de2)
Solutions
- Verify the cluster name and that the configured region matches the cluster's actual region.
- Grant roles/dataproc.viewer to the calling service account.
- Check the cluster still exists (dataproc clusters list) — NOT_FOUND means it was deleted.
- Inspect the wrapped (%w) gRPC status for the definitive cause.
Example fix
// before: wrong region in source config region: "us-west1" // cluster is in us-central1 // after region: "us-central1"
Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the cluster exists in the region before fetching
pager := iterator.NewPager(client.ListClusters(ctx, &dataprocpb.ListClustersRequest{ProjectId: project, Region: region}), 100, "")
var found bool
var pbs []*dataprocpb.Cluster
for {
tok, err := pager.NextPage(&pbs)
if err != nil { return err }
for _, c := range pbs { if c.ClusterName == clusterName { found = true } }
if found || tok == "" { break }
}
if !found { return fmt.Errorf("cluster %q not found in region %s", clusterName, region) } Type guard
null
Try / catch
cluster, err := src.GetCluster(ctx, clusterName)
if err != nil {
if strings.Contains(err.Error(), "NotFound") || strings.Contains(err.Error(), "not found") {
// treat as missing resource: verify name/region, don't retry
}
return err
} Prevention
- Verify cluster name and region with `gcloud dataproc clusters list` before calling.
- Remember auto-deleted/idle clusters may vanish; handle NOT_FOUND gracefully.
- Ensure the source config region matches the cluster's region.
When it happens
Trigger: Calling get-cluster with a clusterName that doesn't exist in the configured region/project, or when the caller lacks dataproc.clusters.get permission, or the regional endpoint is unreachable.
Common situations: Cluster deleted (or auto-deleted after idle) before the call; cluster lives in a different region than configured; typo in cluster name; missing IAM roles.
Related errors
- error getting AlloyDB cluster: %w
- error getting AlloyDB instance: %w
- error getting AlloyDB user: %w
- allowedDataset '%s' not found in project '%s'
- failed to get instance: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/287de6137a3188a6.
Report an issue: GitHub.