googleapis/mcp-toolbox · error

failed to create dataproc job client: %w

Error message

failed to create dataproc job client: %w

What it means

Thrown by the Dataproc source's Config.Initialize when dataproc.NewJobControllerClient fails after both the cluster controller and operations clients were created. Both prior clients are closed before returning to prevent resource leaks. Initialization of the whole dataproc source fails.

Source

Thrown at internal/sources/dataproc/dataproc.go:85

	ua, err := util.UserAgentFromContext(ctx)
	if err != nil {
		return nil, fmt.Errorf("error in User Agent retrieval: %s", err)
	}
	endpoint := fmt.Sprintf("%s-dataproc.googleapis.com:443", r.Region)
	client, err := dataproc.NewClusterControllerClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))
	if err != nil {
		return nil, fmt.Errorf("failed to create dataproc client: %w", err)
	}
	opsClient, err := longrunning.NewOperationsClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))
	if err != nil {
		client.Close()
		return nil, fmt.Errorf("failed to create longrunning client: %w", err)
	}
	jobClient, err := dataproc.NewJobControllerClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))
	if err != nil {
		client.Close()
		opsClient.Close()
		return nil, fmt.Errorf("failed to create dataproc job client: %w", err)
	}

	s := &Source{
		Config:    r,
		Client:    client,
		OpsClient: opsClient,
		JobClient: jobClient,
	}
	return s, nil
}

var _ sources.Source = &Source{}

type Source struct {
	Config
	Client    *dataproc.ClusterControllerClient
	OpsClient *longrunning.OperationsClient
	JobClient *dataproc.JobControllerClient

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Retry initialization; verify stable network access to the regional endpoint.
  2. Validate credentials and ensure the Dataproc API is enabled.
  3. Inspect the wrapped (%w) error for the specific gRPC status.
  4. Ensure connection/firewall limits allow multiple concurrent gRPC channels.
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

src, err := cfg.Initialize(ctx, tracer)
if err != nil {
    if strings.Contains(err.Error(), "dataproc job client") {
        // retry initialization; prior clients are already closed by the library
    }
    return err
}

Prevention

When it happens

Trigger: Third client creation (JobController) against `<region>-dataproc.googleapis.com:443` fails — network interruption mid-initialization, quota/connection limits, or auth errors.

Common situations: Same family as the other client-creation failures: regional endpoint problems, proxies killing long-lived connections, credentials expiring during setup.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/5ac813f41be0129f. Report an issue: GitHub.