{"record":{"id":"9f00b9bf4f0f98d5","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-9f00b9","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/dataplexlookupcontext/dataplexlookupcontext.go","lineNumber":104,"sourceCode":"// validate interface\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\tresourcesSlice, err := parameters.ConvertAnySliceToTyped(paramsMap[\"resources\"].([]any), \"string\")\n\tif err != nil {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"can't convert resources to array of strings: %s\", err), err)\n\t}\n\tresources := resourcesSlice.([]string)\n\n\tif len(resources) == 0 {\n\t\terr := fmt.Errorf(\"resources cannot be empty\")","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/dataplex/dataplexlookupcontext/dataplexlookupcontext.go#L86-L122","documentation":"The dataplex-lookup-context tool requires a source implementing its compatibleSource interface (LookupContext method). ValidateSource returns this error when the injected source is not that type. It guards against mismatched source/tool wiring in the toolbox configuration.","triggerScenarios":"ValidateSource is called with a sources.Source that does not implement compatibleSource (LookupContext(ctx, name, resources)) for dataplex-lookup-context.","commonSituations":"Tool config points at a wrong source (e.g. a database source instead of dataplex); hand-edited YAML with a typo in the source name resolving to another source.","solutions":["Attach a dataplex source to the tool in the YAML config","Check the source name referenced by the tool exists and is of kind dataplex","Run the server and verify startup validation passes for this tool"],"exampleFix":"// before\nsource: cloud-sql-postgres\n// after\nsource: dataplex","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(interface {\n\tLookupContext(ctx context.Context, name string, resources []string) (*dataplex.GoogleCloudDataplexV1LookupContextResponse, error)\n}); !ok {\n\treturn fmt.Errorf(\"source %T does not support LookupContext\", src)\n}","typeGuard":"func isDataplexLookupContextSource(s sources.Source) bool {\n\t_, ok := s.(interface {\n\t\tLookupContext(ctx context.Context, name string, resources []string) (*dataplex.GoogleCloudDataplexV1LookupContextResponse, error)\n\t})\n\treturn ok\n}","tryCatchPattern":"err := tool.ValidateSource(src)\nif err != nil {\n\t// incompatible source: correct the tool->source mapping and reinit\n\treturn fmt.Errorf(\"rebind tool to a dataplex source: %w\", err)\n}","preventionTips":["Keep one dataplex source and reference it explicitly by name in each dataplex tool","Validate config with startup checks before serving traffic","Avoid copying tool blocks across integrations without updating source"],"tags":["go","dataplex","type-mismatch","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"}