{"record":{"id":"a5e2783702f8e86b","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-datachatclient-w","errorCode":null,"errorMessage":"failed to create DataChatClient: %w","messagePattern":"failed to create DataChatClient: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudgda/cloud_gda.go","lineNumber":80,"sourceCode":"\treturn SourceType\n}\n\n// Initialize initializes a Gemini Data Analytics Source instance.\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tua, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error in User Agent retrieval: %s\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig:    r,\n\t\tuserAgent: ua,\n\t}\n\n\tif !r.UseClientOAuth {\n\t\tclient, err := NewDataChatClient(ctx, option.WithUserAgent(ua))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create DataChatClient: %w\", err)\n\t\t}\n\t\ts.Client = client\n\t}\n\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {\n\tConfig\n\tClient    *geminidataanalytics.DataChatClient\n\tuserAgent string\n}\n\nfunc (s *Source) IsReadOnly() bool {\n\treturn false\n}","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudgda/cloud_gda.go#L62-L98","documentation":"When the cloudgda source is not configured for client-side OAuth, Initialize creates a shared google.golang.org/api geminidataanalytics.DataChatClient with the server's Application Default Credentials. Failure to construct that client aborts source initialization with this wrapped error.","triggerScenarios":"UseClientOAuth is false (or unset) and NewDataChatClient fails — typically because ADC are absent, the Gemini Data Analytics API is not enabled on the project, or the client options are invalid.","commonSituations":"Running the toolbox in an environment without GOOGLE_APPLICATION_CREDENTIALS or metadata-server credentials, or a GCP project where the Cloud Gemini/Data Analytics API hasn't been enabled.","solutions":["Set up Application Default Credentials (gcloud auth application-default login or a service-account key via GOOGLE_APPLICATION_CREDENTIALS)","Enable the Gemini Data Analytics API on the project in Google Cloud Console","Set UseClientOAuth: true in the source config to use the caller's OAuth token instead of ADC","Check the wrapped error for quota or API-disabled details"],"exampleFix":"// before\nsource: my-gda\n  kind: cloud-gda\n  project: my-project\n// after\nsource: my-gda\n  kind: cloud-gda\n  project: my-project\n  useClientOAuth: true","handlingStrategy":"try-catch","validationCode":"// verify ADC before initializing\ncreds, err := google.FindDefaultCredentials(ctx, \"https://www.googleapis.com/auth/cloud-platform\")\nif err != nil { return fmt.Errorf(\"ADC unavailable: %w\", err) }\n_ = creds","typeGuard":null,"tryCatchPattern":"// Go: wrap Initialize and surface the wrapped client error\nsrc, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n    if strings.Contains(err.Error(), \"DataChatClient\") {\n        return fmt.Errorf(\"check ADC / enable Gemini Data Analytics API: %w\", err)\n    }\n    return err\n}","preventionTips":["Set GOOGLE_APPLICATION_CREDENTIALS or run gcloud auth application-default login before startup","Enable the Gemini Data Analytics API on the project","Use UseClientOAuth: true when deploying where server credentials are impractical","Smoke-test client creation in CI with a minimal project"],"tags":["cloudgda","google-cloud","authentication","client-initialization"],"backgroundTag":"adc-credentials-missing","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"}