googleapis/mcp-toolbox · error

failed to create Dataplex DataProduct client for project %q:

Error message

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

What it means

The third Dataplex client (DataProduct API) is created with dataplexapi.NewDataProductClient. On failure, the previously created Catalog and DataScan clients are both closed before returning this wrapped error. Since two clients already constructed successfully, credentials and transport are likely fine and this points at a transient or version-specific failure.

Source

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

		}
	}

	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
}

func (s *Source) LookupEntry(ctx context.Context, name string, view int, aspectTypes []string, entry string) (*dataplexpb.Entry, error) {
	viewMap := map[int]dataplexpb.EntryView{
		1: dataplexpb.EntryView_BASIC,
		2: dataplexpb.EntryView_FULL,
		3: dataplexpb.EntryView_CUSTOM,

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Retry initialization — the first two clients succeeded, so this is likely transient.
  2. Update cloud.google.com/go/dataplex to the latest version (DataProduct client is newer; older versions may fail).
  3. Check file-descriptor/connection limits if running in constrained containers (ulimit -n).
  4. Verify the dataplex.googleapis.com API is enabled and reachable; if your library version predates the DataProduct API, upgrading is mandatory.
Defensive patterns

Strategy: retry

Validate before calling

go list -m cloud.google.com/go/dataplex  # verify recent version supporting NewDataProductClient

Try / catch

src, err := cfg.Initialize(ctx, tracer)
if err != nil {
	if strings.Contains(err.Error(), "failed to create Dataplex DataProduct client") {
		return backoff.Retry(func() error { _, err := cfg.Initialize(ctx, tracer); return err }, backoff.NewExponentialBackOff())
	}
	return err
}

Prevention

When it happens

Trigger: initDataplexConnection calls dataplexapi.NewDataProductClient(ctx, opts...) after Catalog and DataScan clients were created; failure triggers cleanup of both and aborts initialization.

Common situations: Older cloud.google.com/go/dataplex versions without DataProduct client support or with API changes; transient gRPC failures; resource exhaustion creating multiple concurrent connections (low fd limits).

Related errors


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