{"record":{"id":"b973e4fda0a85291","repo":"googleapis/mcp-toolbox","slug":"failed-to-get-catalog-client-w","errorCode":null,"errorMessage":"failed to get catalog client: %w","messagePattern":"failed to get catalog client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/searchcatalog/search_catalog.go","lineNumber":173,"sourceCode":"\n\ttypesSlice, err := parameters.ConvertAnySliceToTyped(paramsMap[\"types\"].([]any), \"string\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't convert types to array of strings: %w\", err)\n\t}\n\ttypes := typesSlice.([]string)\n\n\tquery := ConstructSearchQuery(prompt, projectIds, parentIds, types, systemName)\n\n\treq := &dataplexpb.SearchEntriesRequest{\n\t\tQuery:          query,\n\t\tName:           fmt.Sprintf(\"projects/%s/locations/global\", projectID),\n\t\tPageSize:       pageSize,\n\t\tSemanticSearch: true,\n\t}\n\n\tcatalogClient, err := getCatalogClient(ctx, tokenStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get catalog client: %w\", err)\n\t}\n\n\treturn ExecuteSearch(ctx, catalogClient, req, typeMap)\n}\n\n// Cache is an interface for a thread-safe, expiring key-value store.\ntype Cache interface {\n\tGet(key string) (any, bool)\n\tSet(key string, value any)\n}\n\n// DataplexClientManager manages Dataplex Catalog clients, including caching and lazy initialization.\ntype DataplexClientManager struct {\n\tUseClientOAuth       bool\n\tCache                Cache\n\tDefaultClientCreator func(ctx context.Context) (*dataplexapi.CatalogClient, error)\n\tOAuthClientCreator   func(ctx context.Context, token string) (*dataplexapi.CatalogClient, error)\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/searchcatalog/search_catalog.go#L155-L191","documentation":"Thrown by InvokeSearchCatalog in the Dataplex tool when getCatalogClient fails to build an authenticated Google Cloud Dataplex Catalog client. This wraps lower-level errors such as missing Application Default Credentials, invalid quota project configuration, or failure constructing the gRPC client. The underlying error is preserved via %w so callers can inspect it.","triggerScenarios":"Calling the dataplex search-catalog tool when the environment lacks valid Google Cloud credentials (ADC not set up), the token/context cannot produce an authorized client, or the CatalogClient construction fails (e.g., bad project, network unreachable to dataplex.googleapis.com).","commonSituations":"Running the toolbox locally without GOOGLE_APPLICATION_CREDENTIALS or gcloud auth; running in an environment without the required Dataplex API scopes; service account without the Dataplex Catalog viewer role; disabled Dataplex API on the project.","solutions":["Authenticate: run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS to a valid service account key.","Enable the Dataplex (Catalog) API on your Google Cloud project and grant the service account dataplex.catalogViewer (or higher) IAM role.","Check outbound network access to dataplex.googleapis.com and inspect the wrapped cause (%w) for the root error.","Verify the client's auth token/scopes are being passed correctly in the request context."],"exampleFix":"// before: run with no credentials\n./toolbox --prebuilt-configs dataplex\n\n// after\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json\ngcloud services enable dataplex.googleapis.com\n./toolbox --prebuilt-configs dataplex","handlingStrategy":"validation","validationCode":"if os.Getenv(\"GOOGLE_APPLICATION_CREDENTIALS\") == \"\" {\n    if _, err := os.Stat(filepath.Join(os.Getenv(\"HOME\"), \".config/gcloud/application_default_credentials.json\")); err != nil {\n        return errors.New(\"no GCP credentials: run `gcloud auth application-default login`\")\n    }\n}","typeGuard":"null","tryCatchPattern":"result, err := invokeSearchCatalog(ctx, ...)\nif err != nil {\n    var credErr *googleapi.Error\n    if errors.Unwrap(err) != nil && strings.Contains(err.Error(), \"credential\") {\n        // prompt user to authenticate\n    }\n    return fmt.Errorf(\"search catalog unavailable: %w\", err)\n}","preventionTips":["Run `gcloud auth application-default login` before starting the toolbox locally.","Set GOOGLE_APPLICATION_CREDENTIALS explicitly in deployment configs.","Grant the Dataplex Catalog viewer role to the service account.","Enable the Dataplex API in the target project ahead of time."],"tags":["gcp","authentication","dataplex","client-initialization"],"backgroundTag":"missing-gcp-credentials","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"}