{"record":{"id":"cffd302f88b5990f","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-cffd30","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/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go","lineNumber":104,"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\tresType, ok := params.AsMap()[typeKey].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a string\", typeKey), nil)\n\t}\n\tresID, ok := params.AsMap()[idKey].(string)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudhealthcare/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go#L86-L122","documentation":"ValidateSource requires the tool's source to implement compatibleSource (Cloud Healthcare source with FHIR/DICOM store access). Sources of other types cannot supply the store/project/dataset context, so validation returns this error.","triggerScenarios":"Calling ValidateSource with a sources.Source that does not satisfy the compatibleSource interface.","commonSituations":"Tool YAML sourceRef pointing at a non-healthcare source; source kind changes after migration; test harnesses using simplified source fakes.","solutions":["Point the tool's sourceRef at a cloudhealthcare source","Fix the source kind in the YAML config","Validate source-tool compatibility when loading config"],"exampleFix":"# before\nsource: bq_source\n# after\nsource: healthcare_fhir","handlingStrategy":"type-guard","validationCode":"if _, ok := source.(compatibleSource); !ok {\n    return fmt.Errorf(\"source %T is not a Cloud Healthcare source\", source)\n}","typeGuard":"func isCompatibleFHIRSource(s sources.Source) bool {\n    _, ok := s.(compatibleSource)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Use cloud-healthcare sources with healthcare FHIR tools","Check sourceRef targets after config edits","Add startup validation for source-tool compatibility"],"tags":["go","config","type-mismatch","mcp-toolbox"],"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"}