googleapis/mcp-toolbox · error

failed to create batch: %w

Error message

failed to create batch: %w

What it means

The Dataproc CreateBatch RPC rejected the batch creation request — common causes are invalid batch spec fields, quota exhaustion, or missing permissions in the target project/location.

Source

Thrown at internal/sources/serverlessspark/serverlessspark.go:180

		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)
	}
	meta, err := op.Metadata()
	if err != nil {
		return nil, fmt.Errorf("failed to get create batch op metadata: %w", err)
	}

	projectID, location, batchID, err := ExtractBatchDetails(meta.GetBatch())
	if err != nil {
		return nil, fmt.Errorf("error extracting batch details from name %q: %v", meta.GetBatch(), err)
	}
	consoleUrl := BatchConsoleURL(projectID, location, batchID)
	logsUrl := BatchLogsURL(projectID, location, batchID, meta.GetCreateTime().AsTime(), time.Time{})

	wrappedResult := map[string]any{
		"opMetadata": meta,
		"consoleUrl": consoleUrl,
		"logsUrl":    logsUrl,
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Validate the batch payload (Spark container image, main class/jar, properties)
  2. Check Dataproc quota and IAM roles for the project/location
  3. Inspect the wrapped gRPC status for the specific rejected field
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/sources/serverlessspark/serverlessspark.go:180 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/3255242fd2284fa3. Report an issue: GitHub.