{"record":{"id":"dbfe9fd567b3cace","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-dataplex-client-w","errorCode":null,"errorMessage":"failed to get dataplex client: %w","messagePattern":"failed to get dataplex client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigquery/bigquery.go","lineNumber":1011,"sourceCode":") func(string) (*dataplexapi.CatalogClient, error) {\n\treturn func(tokenString string) (*dataplexapi.CatalogClient, error) {\n\t\treturn initDataplexConnectionWithOAuthToken(ctx, project, userAgent, tokenString)\n\t}\n}\n\nfunc (s *Source) InvokeSearchCatalog(ctx context.Context, params map[string]any, tokenStr string) ([]searchcatalog.DataplexSearchResponse, error) {\n\ttypeMap := map[string]string{\n\t\t\"bigquery-connection\":  \"CONNECTION\",\n\t\t\"bigquery-data-policy\": \"POLICY\",\n\t\t\"bigquery-dataset\":     \"DATASET\",\n\t\t\"bigquery-model\":       \"MODEL\",\n\t\t\"bigquery-routine\":     \"ROUTINE\",\n\t\t\"bigquery-table\":       \"TABLE\",\n\t\t\"bigquery-view\":        \"VIEW\",\n\t}\n\tcatalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get dataplex client: %w\", err)\n\t}\n\treturn searchcatalog.InvokeSearchCatalog(\n\t\tctx,\n\t\tparams,\n\t\ttokenStr,\n\t\t\"bigquery\",\n\t\t\"datasetIds\",\n\t\ttypeMap,\n\t\ts.BigQueryProject(),\n\t\tfunc(ctx context.Context, token string) (*dataplexapi.CatalogClient, error) {\n\t\t\tif token != \"\" {\n\t\t\t\treturn dataplexClientCreator(token)\n\t\t\t}\n\t\t\treturn catalogClient, nil\n\t\t},\n\t)\n}\n","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigquery/bigquery.go#L993-L1029","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\ncatalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to get dataplex client: %w\", err)\n}\n// after\ncatalogClient, dataplexClientCreator, err := s.MakeDataplexCatalogClient()()\nif err != nil {\n    return nil, fmt.Errorf(\"failed to get dataplex client (check token validity and Dataplex API enablement for project): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"tok, err := findTokenFromCtx(ctx)\nif err != nil || tok == \"\" {\n    return errors.New(\"no valid access token available for Dataplex catalog search\")\n}\nresp, err := http.Get(\"https://dataplex.googleapis.com/\")\nif err != nil {\n    return fmt.Errorf(\"Dataplex endpoint unreachable: %w\", err)\n}\nresp.Body.Close()","typeGuard":"func isClientInitError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"failed to create Dataplex client\")\n}","tryCatchPattern":"catalogClient, creator, err := s.MakeDataplexCatalogClient()()\nif err != nil {\n    if isClientInitError(err) {\n        return nil, fmt.Errorf(\"re-authenticate and retry; client init failed: %w\", err)\n    }\n    return nil, fmt.Errorf(\"failed to get dataplex client: %w\", err)\n}","preventionTips":["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."],"tags":["gcp","dataplex","client-initialization","authentication"],"backgroundTag":"gcp-client-init-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}