{"record":{"id":"089d0bda9a9e651f","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-089d0b","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/dataplexgeneratedataprofile/dataplexgeneratedataprofile.go","lineNumber":98,"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\tresourcePath, _ := paramsMap[\"resourcePath\"].(string)\n\tlocation, _ := paramsMap[\"location\"].(string)\n\tpublish, _ := paramsMap[\"publish\"].(bool)\n\n\tif resourcePath == \"\" {\n\t\treturn nil, util.NewAgentError(\"resourcePath parameter is required\", nil)\n\t}\n\tif location == \"\" {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/dataplex/dataplexgeneratedataprofile/dataplexgeneratedataprofile.go#L80-L116","documentation":"This error comes from the Dataplex tool's ValidateSource method when the sources.Source passed to the tool does not implement the tool's `compatibleSource` interface (a Go type assertion `source.(compatibleSource)` fails). Each Dataplex tool defines a narrow interface (e.g., `GenerateDataProfile(ctx, ...)`) that the configured source must satisfy; a source of the wrong kind (or a mock/stub missing the method) is rejected before Invoke runs. It is a static wiring/configuration check ensuring the tool only runs against a source capable of calling the Dataplex API.","triggerScenarios":"Calling tools.ValidateSource (or the server wiring that invokes it) with a sources.Source whose concrete type does not implement the dataplexgeneratedataprofile `compatibleSource` interface, e.g., attaching a dataplex source that lacks GenerateDataProfile, a different database source entirely, or a test stub that does not implement the method set.","commonSituations":"YAML config wires a tool to a source of the wrong `kind`; a custom or older source implementation predates the GenerateDataProfile method; a developer's test fake implements sources.Source but not the tool's compatibleSource interface; a refactor renamed or changed the signature of GenerateDataProfile so the source no longer satisfies the interface.","solutions":["Set the tool's `source` in the YAML config to a Dataplex source whose implementation implements the GenerateDataProfile method required by compatibleSource.","Check the compatibleSource interface at the top of internal/tools/dataplex/dataplexgeneratedataprofile/dataplexgeneratedataprofile.go and confirm your source's concrete type implements exactly that method signature.","If using a custom source, add the missing method (e.g., GenerateDataProfile(ctx, ...)) with the exact signature from the interface.","In tests, make the fake source embed or implement the tool's compatibleSource interface instead of only sources.Source."],"exampleFix":"// before: tool wired to incompatible source in tools.yaml\n// tools:\n//   generate-profile:\n//     kind: dataplex-generate-data-profile\n//     source: my-postgres-source   # wrong: postgres source lacks GenerateDataProfile\n//\n// after\n// tools:\n//   generate-profile:\n//     kind: dataplex-generate-data-profile\n//     source: my-dataplex-source   # dataplex source implements compatibleSource","handlingStrategy":"type-guard","validationCode":"src, ok := mySource.(interface {\n\tGenerateDataProfile(ctx context.Context, projectId, locationId, dataProductId, dataAssetId string) (*dataplex.DataProfileResult, error)\n})\nif !ok {\n\treturn fmt.Errorf(\"source %T is not compatible with dataplex-generate-data-profile\", mySource)\n}","typeGuard":"func isGenerateDataProfileSource(s sources.Source) bool {\n\t_, ok := s.(dataplexgeneratedataprofile.CompatibleSource)\n\treturn ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tvar invalidSource *util.InvalidSourceError\n\tif errors.As(err, &invalidSource) {\n\t\t// fix tool/source wiring: fall back to a Dataplex source or surface config error\n\t\treturn nil, fmt.Errorf(\"wiring: %w\", err)\n\t}\n\treturn nil, err\n}","preventionTips":["Always pair dataplex-* tool kinds with a dataplex-kind source in tools.yaml.","Add compile-time interface assertions (var _ compatibleSource = (*Source)(nil)) in source packages.","Run unit tests that call ValidateSource for every tool/source combination in your config.","Validate the full tools.yaml at startup before serving traffic."],"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"}