{"record":{"id":"31ec842d442baa7b","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-31ec84","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/dataplexgetdataasset/dataplexgetdataasset.go","lineNumber":101,"sourceCode":"\ntype Tool struct {\n\ttools.BaseTool[Config]\n}\n\nvar _ tools.Tool = Tool{}\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/dataplexgetdataasset/dataplexgetdataasset.go#L83-L119","documentation":"This error is thrown by the dataplexgetdataasset tool's ValidateSource when the provided sources.Source fails the type assertion to the tool's `compatibleSource` interface, which requires a GetDataAsset(ctx, locationId, dataProductId, dataAssetId) method. The tool refuses to operate on any source that cannot perform the underlying Dataplex API lookup. This prevents runtime nil-method panics by failing fast at validation time.","triggerScenarios":"Calling ValidateSource with a source whose concrete Go type does not implement GetDataAsset with the exact signature `(ctx context.Context, locationId string, dataProductId string, dataAssetId string) (*dataplex.DataAsset, error)` — e.g., a non-Dataplex source, or a Dataplex source variant missing that method.","commonSituations":"Configuring the tool against a source of a different kind in tools.yaml; using an outdated Dataplex source implementation before GetDataAsset was added; test doubles that only satisfy sources.Source; version skew between the tool package and a vendored source package.","solutions":["Point the tool's `source` config field at a Dataplex source that implements GetDataAsset.","Verify your source's concrete type satisfies the compatibleSource interface declared in internal/tools/dataplex/dataplexgetdataasset/dataplexgetdataasset.go:46.","If implementing a custom source, add GetDataAsset with the exact signature from the interface.","Update the source implementation/package if it predates the GetDataAsset method."],"exampleFix":"// before\n// kind: dataplex-get-data-asset\n// source: bigquery-source   # does not implement GetDataAsset\n//\n// after\n// kind: dataplex-get-data-asset\n// source: dataplex-source   # implements compatibleSource.GetDataAsset","handlingStrategy":"type-guard","validationCode":"type dataAssetSource interface {\n\tGetDataAsset(ctx context.Context, locationId, dataProductId, dataAssetId string) (*dataplex.DataAsset, error)\n}\nvar _ dataAssetSource = sources.Dataplex{} // compile-time check","typeGuard":"func isGetdataAssetSource(s sources.Source) bool {\n\t_, ok := s.(interface {\n\t\tGetDataAsset(ctx context.Context, locationId, dataProductId, dataAssetId string) (*dataplex.DataAsset, error)\n\t})\n\treturn ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\tlog.Printf(\"incompatible source for %s: %v\", tool.GetName(), err)\n\treturn nil, err // do not retry; fix the source wiring\n}","preventionTips":["Check the tool's compatibleSource interface before choosing a source kind.","Use compile-time assertions to keep custom sources compliant.","Cover tool/source pairing in integration tests.","Avoid renaming tool-facing source methods without updating all dataplex tools."],"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"}