{"record":{"id":"2e3081f31b4702ef","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-2e3081","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/dataplexgetdiscoveryresults/dataplexgetdiscoveryresults.go","lineNumber":99,"sourceCode":"\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\tscanId, _ := paramsMap[\"scanId\"].(string)\n\tlocation, _ := paramsMap[\"location\"].(string)\n\n\tif scanId == \"\" {\n\t\treturn nil, util.NewAgentError(\"scanId parameter is required\", nil)\n\t}\n\tif location == \"\" {\n\t\treturn nil, util.NewAgentError(\"location parameter is required\", nil)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/dataplex/dataplexgetdiscoveryresults/dataplexgetdiscoveryresults.go#L81-L117","documentation":"The dataplexgetdiscoveryresults tool's ValidateSource returns this error when a type assertion of the supplied source to the tool's `compatibleSource` interface (GetDiscoveryResults method) fails. The tool only works with sources that can retrieve Dataplex discovery scan results, so incompatible sources are rejected at validation. It signals miswiring between the tool config and the source registry, not a Dataplex-side problem.","triggerScenarios":"Calling ValidateSource with a source missing GetDiscoveryResults — for example, after binding the tool to a different source kind in tools.yaml, or constructing a Tool with a Config referencing a source that never implemented the discovery method.","commonSituations":"Wrong `source:` value in the tool YAML; custom source integrations missing the method; interface drift after API signature changes; test doubles that don't implement the tool-specific interface.","solutions":["Set the tool's `source` to a Dataplex source implementing GetDiscoveryResults.","Check your source's method set against compatibleSource in internal/tools/dataplex/dataplexgetdiscoveryresults/dataplexgetdiscoveryresults.go.","Add GetDiscoveryResults with the exact interface signature to custom sources.","Add a compile-time check `var _ compatibleSource = (*MySource)(nil)` in the source package."],"exampleFix":"// before: fake in test\n// type src struct{} // implements sources.Source only\n//\n// after\n// type src struct{}\n// func (src) GetDiscoveryResults(ctx context.Context, locationId, datascansId string) (*dataplex.DataSource, error) { ... }","handlingStrategy":"type-guard","validationCode":"var _ interface {\n\tGetDiscoveryResults(ctx context.Context, /* params */) (*dataplex.DataSource, error)\n} = (*myDataplexSource)(nil)","typeGuard":"func isDiscoverySource(s sources.Source) bool {\n\t_, ok := s.(dataplexgetdiscoveryresults.CompatibleSource)\n\treturn ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tif strings.Contains(err.Error(), \"not a compatible type\") {\n\t\treturn nil, fmt.Errorf(\"tool %q requires a dataplex source implementing GetDiscoveryResults\", toolName)\n\t}\n\treturn nil, err\n}","preventionTips":["Add compile-time interface checks for every source implementing dataplex tools.","Test tool/source compatibility at startup and in CI.","Avoid mixing tool configs from different toolbox versions.","Document the compatible source kind in tool config comments."],"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"}