googleapis/mcp-toolbox · error
failed to get operations client: %w
Error message
failed to get operations client: %w
What it means
GetOperationsClient, which normally just returns the pre-initialized s.OpsClient, returned an error inside CancelOperation; this is a defensive guard since the current implementation always returns nil error — failure here means the stored client is unusable.
Source
Thrown at internal/sources/serverlessspark/serverlessspark.go:162
func (s *Source) GetSessionControllerClient() *dataproc.SessionControllerClient {
return s.SessionClient
}
func (s *Source) GetOperationsClient(ctx context.Context) (*longrunning.OperationsClient, error) {
return s.OpsClient, nil
}
func (s *Source) Close() error {
return errors.Join(s.BatchClient.Close(), s.SessionClient.Close(), s.SessionTemplateClient.Close(), s.OpsClient.Close())
}
func (s *Source) CancelOperation(ctx context.Context, operation string) (any, error) {
req := &longrunningpb.CancelOperationRequest{
Name: fmt.Sprintf("projects/%s/locations/%s/operations/%s", s.GetProject(), s.GetLocation(), operation),
}
client, err := s.GetOperationsClient(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get operations client: %w", err)
}
err = client.CancelOperation(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to cancel operation: %w", err)
}
return fmt.Sprintf("Cancelled [%s].", operation), nil
}
func (s *Source) CreateBatch(ctx context.Context, batch *dataprocpb.Batch) (map[string]any, error) {
req := &dataprocpb.CreateBatchRequest{
Parent: fmt.Sprintf("projects/%s/locations/%s", s.GetProject(), s.GetLocation()),
Batch: batch,
}
client := s.GetBatchControllerClient()
op, err := client.CreateBatch(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to create batch: %w", err)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Check whether the source was fully initialized (all clients created in Initialize)
- Recreate/reinitialize the Serverless Spark source if its clients were closed
- Inspect the wrapped error for the underlying Google API cause
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/sources/serverlessspark/serverlessspark.go:162 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/ecf773100485482d.
Report an issue: GitHub.