{"record":{"id":"143681fe24457bb7","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-143681","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/dataplexgetdataprofile/dataplexgetdataprofile.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/dataplexgetdataprofile/dataplexgetdataprofile.go#L81-L117","documentation":"The dataplexgetdataprofile tool's ValidateSource emits this error when `source.(compatibleSource)` fails — the supplied source does not implement the GetDataProfile method the tool needs. This guard ensures the tool never invokes a method that doesn't exist on the wired source. The error reflects a tool/source type mismatch in configuration or code, not a runtime API failure.","triggerScenarios":"Calling ValidateSource with a non-Dataplex source, a Dataplex source lacking GetDataProfile(ctx, locationId, dataAssetId), or a test double that only implements sources.Source.","commonSituations":"Wrong source referenced in the tool's YAML block; custom or legacy source implementations missing the profile-lookup method; method signature changes during refactors breaking interface satisfaction; mixing tool definitions from different releases.","solutions":["Point the tool's `source` config at a Dataplex source implementing GetDataProfile.","Verify interface satisfaction against compatibleSource in internal/tools/dataplex/dataplexgetdataprofile/dataplexgetdataprofile.go.","Add/repair the GetDataProfile method on custom sources to match the interface.","Add a compile-time assertion `var _ compatibleSource = (*mySource)(nil)` to catch drift early."],"exampleFix":"// before\n// func (s *MySource) GetDataProfile(ctx context.Context, id string) (*dataplex.DataProfileResult, error) // wrong signature\n//\n// after: match interface exactly\n// func (s *MySource) GetDataProfile(ctx context.Context, locationId, dataAssetId string) (*dataplex.DataProfileResult, error)","handlingStrategy":"type-guard","validationCode":"var _ interface {\n\tGetDataProfile(ctx context.Context, locationId, dataAssetId string) (*dataplex.DataProfileResult, error)\n} = (*myDataplexSource)(nil)","typeGuard":"func isGetDataProfileSource(s sources.Source) bool {\n\t_, ok := s.(dataplexgetdataprofile.CompatibleSource)\n\treturn ok\n}","tryCatchPattern":"err := tool.ValidateSource(src)\nif err != nil {\n\tvar ve *util.ToolboxError\n\tif errors.As(err, &ve) {\n\t\treturn nil, fmt.Errorf(\"reconfigure tool %q with a dataplex source\", toolName)\n\t}\n\treturn nil, err\n}","preventionTips":["Embed interface assertions in source implementations.","Review tools.yaml tool->source mappings during code review.","Run `go vet`/unit tests that exercise ValidateSource.","Pin tool and source implementations to the same 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"}