{"record":{"id":"edfd329add185152","repo":"googleapis/mcp-toolbox","slug":"error-constructing-service-creator-w","errorCode":null,"errorMessage":"error constructing service creator: %w","messagePattern":"error constructing service creator: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":95,"sourceCode":"}\n\nfunc (c Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (c Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tvar service *healthcare.Service\n\tvar serviceCreator HealthcareServiceCreator\n\tvar tokenSource oauth2.TokenSource\n\n\tsvc, tok, err := initHealthcareConnection(ctx, tracer, c.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating service from ADC: %w\", err)\n\t}\n\tif c.UseClientOAuth {\n\t\tserviceCreator, err = newHealthcareServiceCreator(ctx, tracer, c.Name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error constructing service creator: %w\", err)\n\t\t}\n\t} else {\n\t\tservice = svc\n\t\ttokenSource = tok\n\t}\n\n\tdsName := fmt.Sprintf(\"projects/%s/locations/%s/datasets/%s\", c.Project, c.Region, c.Dataset)\n\tif _, err = svc.Projects.Locations.Datasets.FhirStores.Get(dsName).Do(); err != nil {\n\t\tif gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {\n\t\t\treturn nil, fmt.Errorf(\"dataset '%s' not found\", dsName)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to verify existence of dataset '%s': %w\", dsName, err)\n\t}\n\n\tallowedFHIRStores := make(map[string]struct{})\n\tfor _, store := range c.AllowedFHIRStores {\n\t\tname := fmt.Sprintf(\"%s/fhirStores/%s\", dsName, store)\n\t\t_, err := svc.Projects.Locations.Datasets.FhirStores.Get(name).Do()","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L77-L113","documentation":"When the cloud-healthcare source is configured with UseClientOAuth, Initialize additionally builds a HealthcareServiceCreator that will construct per-request services from caller tokens; failure to construct this creator yields this wrapped error and stops initialization.","triggerScenarios":"UseClientOAuth: true and newHealthcareServiceCreator fails during Initialize — typically ADC/credential setup needed to bootstrap the creator itself fails, or client options for the healthcare endpoint are invalid (bad project/location/endpoint).","commonSituations":"Client-OAuth setups bootstrapped in environments that still lack baseline credentials or with a misconfigured custom endpoint for the Healthcare API.","solutions":["Ensure baseline ADC exist even in client-OAuth mode, if the creator requires them for bootstrapping","Verify the configured project, location, and custom endpoint values are valid","Check the wrapped error for the concrete construction failure","Confirm the Cloud Healthcare API is enabled and the network can reach googleapis.com"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure bootstrap credentials and endpoint config exist before Initialize\nif cfg.UseClientOAuth {\n    if _, err := google.FindDefaultCredentials(ctx, \"https://www.googleapis.com/auth/cloud-platform\"); err != nil {\n        return fmt.Errorf(\"client-OAuth mode still needs bootstrap ADC: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide baseline ADC even in client-OAuth deployments","Double-check project/location/endpoint values in the source YAML","Enable the Cloud Healthcare API on the project","Test source initialization at startup, not on first tool call"],"tags":["cloudhealthcare","google-cloud","oauth","initialization"],"backgroundTag":"api-client-creation-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"}