googleapis/mcp-toolbox · error

failed to create Dataplex DataScan client for project %q: %w

Error message

failed to create Dataplex DataScan client for project %q: %w

What it means

The second Dataplex client (DataScan API) is created with dataplexapi.NewDataScanClient. On failure, the already-created Catalog client is closed and this wrapped error is returned. Causes mirror the Catalog client failure: transport, options, or connectivity problems with the datascans endpoint of the Dataplex API.

Source

Thrown at internal/sources/dataplex/dataplex.go:235

		cred, err := google.FindDefaultCredentials(ctx, credScopes...)
		if err != nil {
			return nil, nil, nil, nil, fmt.Errorf("failed to find default Google Cloud credentials for project %q: %w", project, err)
		}
		opts = []option.ClientOption{
			option.WithUserAgent(userAgent),
			option.WithCredentials(cred),
		}
	}

	client, err := dataplexapi.NewCatalogClient(ctx, opts...)
	if err != nil {
		return nil, nil, nil, nil, fmt.Errorf("failed to create Dataplex client for project %q: %w", project, err)
	}

	dataScanClient, err := dataplexapi.NewDataScanClient(ctx, opts...)
	if err != nil {
		client.Close()
		return nil, nil, nil, nil, fmt.Errorf("failed to create Dataplex DataScan client for project %q: %w", project, err)
	}

	dataProductClient, err := dataplexapi.NewDataProductClient(ctx, opts...)
	if err != nil {
		client.Close()
		dataScanClient.Close()
		return nil, nil, nil, nil, fmt.Errorf("failed to create Dataplex DataProduct client for project %q: %w", project, err)
	}

	projectsClient, err := resourcemanager.NewProjectsClient(ctx, opts...)
	if err != nil {
		client.Close()
		dataScanClient.Close()
		dataProductClient.Close()
		return nil, nil, nil, nil, fmt.Errorf("failed to create ResourceManager projects client for project %q: %w", project, err)
	}

	return client, dataScanClient, dataProductClient, projectsClient, nil

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check connectivity to dataplex.googleapis.com (DataScan is served by the same API, so retry usually resolves transient failures).
  2. Re-run initialization — since Catalog creation succeeded, credentials are valid; this is likely transient.
  3. Update cloud.google.com/go/dataplex and google.golang.org/api to compatible latest versions.
  4. Verify proxy/firewall rules aren't dropping the second concurrent gRPC connection.
Defensive patterns

Strategy: retry

Validate before calling

curl -sS --max-time 5 https://dataplex.googleapis.com/ >/dev/null && echo reachable || echo unreachable

Try / catch

src, err := cfg.Initialize(ctx, tracer)
if err != nil {
	if strings.Contains(err.Error(), "failed to create Dataplex DataScan client") {
		// catalog client succeeded, so likely transient; retry after backoff
		return backoff.Retry(func() error { _, err := cfg.Initialize(ctx, tracer); return err }, backoff.NewExponentialBackOff())
	}
	return err
}

Prevention

When it happens

Trigger: initDataplexConnection calls dataplexapi.NewDataScanClient(ctx, opts...) after a successful NewCatalogClient; failure closes the Catalog client and aborts initialization.

Common situations: Same network/proxy issues as the Catalog client; intermittent gRPC channel failures mid-initialization; library version mismatches between dataplex client and google.golang.org/api dependencies.

Related errors


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