{"record":{"id":"91f5bc9a1c53879e","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-91f5bc","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/dataplexgetdatainsights/dataplexgetdatainsights.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/dataplexgetdatainsights/dataplexgetdatainsights.go#L81-L117","documentation":"The dataplexgetdatainsights tool's ValidateSource returns this error when the injected sources.Source does not satisfy the tool's private `compatibleSource` interface (a GetDataInsights method). This is a fail-fast guard: the type assertion `source.(compatibleSource)` fails, so the tool reports that the source is not a compatible type rather than attempting an API call. It indicates a tool-to-source wiring mismatch, not a Dataplex API problem.","triggerScenarios":"Passing any sources.Source to ValidateSource that lacks the GetDataInsights method signature required by this tool's compatibleSource interface — e.g., wiring the tool to a non-Dataplex source in the YAML config, or supplying a mock in tests.","commonSituations":"Copy-pasted tool configs referencing the wrong source name; a custom source implementation missing the GetDataInsights method; interface drift after refactoring the source's method signature; running an old binary where the source kind was registered differently.","solutions":["Configure the tool with a `source` that is a Dataplex source implementing GetDataInsights.","Compare your source's method set against the compatibleSource interface in internal/tools/dataplex/dataplexgetdatainsights/dataplexgetdatainsights.go.","Add or fix the GetDataInsights method on your custom source to match the interface exactly.","Rebuild/redeploy with a current source implementation if the interface drifted."],"exampleFix":"// before: test stub missing method\n// type fakeSource struct{}\n// func (f fakeSource) SourceType() string { return \"dataplex\" }\n//\n// after\n// type fakeSource struct{}\n// func (f fakeSource) SourceType() string { return \"dataplex\" }\n// func (f fakeSource) GetDataInsights(ctx context.Context, /* params */) (*dataplex.Facet, error) { ... }","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(interface {\n\tGetDataInsights(ctx context.Context, /* params */) (*dataplex.Facet, error)\n}); !ok {\n\treturn errors.New(\"source does not support dataplex-get-data-insights\")\n}","typeGuard":"func isGetDataInsightsSource(s sources.Source) bool {\n\t_, ok := s.(dataplexgetdatainsights.CompatibleSource)\n\treturn ok\n}","tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil { /* not needed: ValidateSource returns error */ }\n}()\nif err := tool.ValidateSource(src); err != nil {\n\treturn nil, fmt.Errorf(\"swap to a dataplex source: %w\", err)\n}","preventionTips":["Wire each dataplex tool to a dataplex source in tools.yaml.","Assert interface satisfaction at compile time in custom sources.","Add ValidateSource checks to config-load tests.","Keep tool and source packages on the same release version."],"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"}