googleapis/mcp-toolbox · error
failed to get dataplex client: %w
Error message
failed to get dataplex client: %w
What it means
This error wraps a failure that occurred while obtaining the Dataplex Catalog client (and creator closure) via s.MakeDataplexCatalogClient()() before invoking a catalog search. The inner error is typically the 'failed to create Dataplex client for project' error from the client constructor. It means searchcatalog.InvokeSearchCatalog could not start because no usable client was produced.
Source
Thrown at internal/sources/bigquery/bigquery.go:1011
) func(string) (*dataplexapi.CatalogClient, error) {
return func(tokenString string) (*dataplexapi.CatalogClient, error) {
return initDataplexConnectionWithOAuthToken(ctx, project, userAgent, tokenString)
}
}
func (s *Source) InvokeSearchCatalog(ctx context.Context, params map[string]any, tokenStr string) ([]searchcatalog.DataplexSearchResponse, error) {
typeMap := map[string]string{
"bigquery-connection": "CONNECTION",
"bigquery-data-policy": "POLICY",
"bigquery-dataset": "DATASET",
"bigquery-model": "MODEL",
"bigquery-routine": "ROUTINE",
"bigquery-table": "TABLE",
"bigquery-view": "VIEW",
}
catalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()
if err != nil {
return nil, fmt.Errorf("failed to get dataplex client: %w", err)
}
return searchcatalog.InvokeSearchCatalog(
ctx,
params,
tokenStr,
"bigquery",
"datasetIds",
typeMap,
s.BigQueryProject(),
func(ctx context.Context, token string) (*dataplexapi.CatalogClient, error) {
if token != "" {
return dataplexClientCreator(token)
}
return catalogClient, nil
},
)
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Inspect the wrapped inner error for the root cause (client creation vs. auth).
- Re-authenticate or refresh the access token used by the BigQuery source.
- Enable the Dataplex API (dataplex.googleapis.com) on the target project.
- Verify network connectivity/proxy settings to Google APIs.
- Re-test with `gcloud dataplex catalog search` or a curl to the endpoint to isolate auth vs. network.
Example fix
// before
catalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()
if err != nil {
return nil, fmt.Errorf("failed to get dataplex client: %w", err)
}
// after
catalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()
if err != nil {
return nil, fmt.Errorf("failed to get dataplex client (check token validity and Dataplex API enablement for project): %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
tok, err := findTokenFromCtx(ctx)
if err != nil || tok == "" {
return errors.New("no valid access token available for Dataplex catalog search")
}
resp, err := http.Get("https://dataplex.googleapis.com/")
if err != nil {
return fmt.Errorf("Dataplex endpoint unreachable: %w", err)
}
resp.Body.Close() Type guard
func isClientInitError(err error) bool {
return err != nil && strings.Contains(err.Error(), "failed to create Dataplex client")
} Try / catch
catalogClient, creator, err := s.MakeDataplexCatalogClient()()
if err != nil {
if isClientInitError(err) {
return nil, fmt.Errorf("re-authenticate and retry; client init failed: %w", err)
}
return nil, fmt.Errorf("failed to get dataplex client: %w", err)
} Prevention
- Refresh tokens before expiry rather than relying on long-lived static tokens.
- Verify the Dataplex API is enabled on the project before configuring the tool.
- Check proxy/firewall reachability of dataplex.googleapis.com in deployment environments.
- Fail fast at source initialization if client creation fails, instead of at search time.
- Log the unwrapped root cause (errors.Unwrap) for quicker diagnosis.
When it happens
Trigger: Invoking the bigquery-search-catalog tool: MakeDataplexCatalogClient()() returns a non-nil error because the underlying dataplexapi.NewCatalogClient call failed (auth token invalid, options error, network/endpoint issue).
Common situations: Expired OAuth access token at tool invocation time, missing BigQuery/Dataplex API enablement on the project, misconfigured source credentials, or offline/proxied environments where the Dataplex endpoint is unreachable.
Related errors
- failed to initialize dataplex client: %w
- failed to get catalog client: %w
- failed to create Dataplex client for project %q: %w
- failed to create impersonated credentials for %q for project
- failed to find default Google Cloud credentials for project
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/dbfe9fd567b3cace.
Report an issue: GitHub.