{"record":{"id":"8f91270da370b69c","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-8f9127","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/dataplex/dataplexgetdataproduct/dataplexgetdataproduct.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\tparamsMap := params.AsMap()\n\tlocationID, ok := paramsMap[\"locationId\"].(string)\n\tif !ok || locationID == \"\" {\n\t\treturn nil, util.NewAgentError(\"locationId is required and must be a non-empty string\", nil)\n\t}\n\tdataProductID, ok := paramsMap[\"dataProductId\"].(string)\n\tif !ok || dataProductID == \"\" {\n\t\treturn nil, util.NewAgentError(\"dataProductId is required and must be a non-empty string\", nil)\n\t}","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/dataplex/dataplexgetdataproduct/dataplexgetdataproduct.go#L83-L119","documentation":"Thrown by the dataplexgetdataproduct tool's ValidateSource when the source passed in cannot be asserted to the tool's `compatibleSource` interface, i.e., it does not implement GetDataProduct with the expected signature. The tool only accepts sources capable of fetching a Dataplex data product, so any other source kind (or an incomplete implementation) is rejected with this message. It's a configuration/compatibility error surfaced before Invoke.","triggerScenarios":"ValidateSource (or server startup wiring) receives a sources.Source whose concrete type is missing GetDataProduct(ctx, locationId, dataProductId) (*dataplex.DataProduct, error); typically from binding the tool to a wrong source in tools.yaml or using a stub in tests.","commonSituations":"Misconfigured tools.yaml where `source:` names a different database's source; custom source integrations that implement sources.Source but not the Dataplex-specific method; stale source implementations after a method rename; copy-paste of tool blocks without updating the source field.","solutions":["Set the tool's `source` to a Dataplex source implementing GetDataProduct.","Check the compatibleSource interface at the top of internal/tools/dataplex/dataplexgetdataproduct/dataplexgetdataproduct.go and align your source's method set.","Implement the missing GetDataProduct method on custom sources with the exact interface signature.","Fix test fakes to embed the tool's compatibleSource interface."],"exampleFix":"// before\n// tools:\n//   get-product:\n//     kind: dataplex-get-data-product\n//     source: mysql-source      # incompatible\n//\n// after\n// tools:\n//   get-product:\n//     kind: dataplex-get-data-product\n//     source: dataplex-source   # implements compatibleSource","handlingStrategy":"validation","validationCode":"// At config load time, before running tools:\nfor name, tl := range loadedTools {\n\tif err := tl.Tool.(interface{ ValidateSource(sources.Source) error }).ValidateSource(loadedSources[tl.Source]); err != nil {\n\t\treturn fmt.Errorf(\"tool %q: %w\", name, err)\n\t}\n}","typeGuard":"func isGetDataProductSource(s sources.Source) bool {\n\t_, ok := s.(interface {\n\t\tGetDataProduct(ctx context.Context, locationId, dataProductId string) (*dataplex.DataProduct, error)\n\t})\n\treturn ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tswitch {\n\tcase strings.Contains(err.Error(), \"not a compatible type\"):\n\t\treturn nil, fmt.Errorf(\"config error: tool requires a dataplex source: %w\", err)\n\tdefault:\n\t\treturn nil, err\n\t}\n}","preventionTips":["Validate every tool/source pair when loading configuration, not at request time.","Match tool kind to source kind by convention (dataplex-* <-> dataplex).","Write table-driven tests pairing each tool with correct and incorrect sources.","Document required source kind in your tool config templates."],"tags":["go","type-assertion","dataplex","source-compatibility","configuration"],"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"}