{"record":{"id":"dd6eefd9eb613b38","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-dd6eef","errorCode":null,"errorMessage":"invalid source for %q tool: source %q is not a compatible type","messagePattern":"invalid source for %q tool: source %q is not a compatible type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go","lineNumber":101,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\n}\n\nfunc (t Tool) ToConfig() tools.ToolConfig {\n\treturn t.Cfg\n}\n\nfunc (t Tool) ValidateSource(source sources.Source) error {\n\t_, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn nil\n}\n\nfunc (t Tool) Invoke(ctx context.Context, s sources.Source, params parameters.ParamValues, accessToken tools.AccessToken) (any, util.ToolboxError) {\n\tsource, ok := s.(compatibleSource)\n\tif !ok {\n\t\treturn nil, util.NewClientServerError(\"source used is not compatible with the tool\", http.StatusInternalServerError, nil)\n\t}\n\tstoreID, err := common.ValidateAndFetchStoreID(params, source.AllowedFHIRStores())\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(\"failed to validate store ID\", err)\n\t}\n\tvar tokenStr string\n\tif source.UseClientAuthorization() {\n\t\ttokenStr, err = accessToken.ParseBearerToken()\n\t\tif err != nil {\n\t\t\treturn nil, util.NewClientServerError(\"error parsing access token\", http.StatusUnauthorized, err)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go#L83-L119","documentation":"ValidateSource asserts the incoming sources.Source to compatibleSource and returns this error when the tool is invoked or wired against a source that is not the Cloud Healthcare source. It is the upfront guard ensuring Invoke only ever sees a source exposing FHIR/DICOM store helpers.","triggerScenarios":"Invoke/ValidateSource called with a non-cloudhealthcare source, e.g. toolset assembly attaching this tool to a different engine's source.","commonSituations":"Wrong source referenced in tools.yaml; source kind renamed after an upgrade so binding resolves to the wrong source; test fakes not updated to the compatibleSource interface.","solutions":["Use a 'cloudhealthcare' kind source for this tool in tools.yaml.","Confirm source registration: the source's SourceType() must equal the cloudhealthcare resource type.","Update mock sources in tests to implement compatibleSource.","Re-run toolbox init after upgrading to regenerate correct bindings."],"exampleFix":"// before\n  source: my-sql-source\n// after\n  source: my-healthcare-source","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(cloudhealthcare.Source); !ok {\n    return errors.New(\"this tool only supports the cloudhealthcare source\")\n}","typeGuard":"func implementsCompatibleSource(s sources.Source) bool {\n    _, ok := s.(interface {\n        UseClientAuthorization() bool\n        AllowedFHIRStores() []string\n        IsFHIRStoreAllowed(string) bool\n    })\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"invalid source binding: %w\", err)\n}","preventionTips":["Bind healthcare tools only to healthcare sources","Run startup validation so ValidateSource fires before traffic","Update test doubles whenever compatibleSource gains methods","Keep source names unique to avoid accidental binding to the wrong entry"],"tags":["go","type-assertion","configuration","cloud-healthcare"],"backgroundTag":"incompatible-source-type","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"}