{"record":{"id":"6c8ed7dc6942f4ea","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-6c8ed7","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/serverlessspark/createbatch/tool.go","lineNumber":68,"sourceCode":"\t\toriginalConfig: originalCfg,\n\t\tBuilder:        builder,\n\t}, nil\n}\n\ntype Tool struct {\n\ttools.BaseTool[Config]\n\toriginalConfig tools.ToolConfig\n\tBuilder        BatchBuilder\n}\n\nfunc (t Tool) GetSourceName() string {\n\treturn t.Cfg.Source\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\tbatch, err := t.Builder.BuildBatch(params)\n\tif err != nil {\n\t\tif tbErr, ok := err.(util.ToolboxError); ok {\n\t\t\treturn nil, tbErr\n\t\t}\n\t\treturn nil, util.NewAgentError(\"failed to build batch\", err)\n\t}\n\n\tif t.Cfg.RuntimeConfig != nil {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/serverlessspark/createbatch/tool.go#L50-L86","documentation":"ValidateSource for the serverlessspark createbatch tool asserts the bound source implements compatibleSource — specifically a source offering CreateBatch(ctx, *dataprocpb.Batch). If the tool is wired to a non-Serverless-Spark source, startup fails with this type-compatibility error naming the tool type and configured source.","triggerScenarios":"Tool config assigns 'type: serverless-spark-create-batch' to a source (e.g. postgres, alloydb) whose Go type does not implement compatibleSource, evaluated when the toolbox loads the config.","commonSituations":"Reusing a shared sources block across tool kinds and pointing a Spark batch tool at a database source; renaming sources so an old source reference now resolves to a different kind.","solutions":["Check the tool's 'source:' reference in the YAML and ensure it points to a serverlessspark kind source","Correct the source reference or add a dedicated serverlessspark source","Restart the server to reload configs"],"exampleFix":"# before\ntools:\n  create-batch:\n    source: my-postgres\n# after\ntools:\n  create-batch:\n    source: my-spark","handlingStrategy":"type-guard","validationCode":"if _, ok := src.(createbatch.CompatibleSource); !ok {\n    return fmt.Errorf(\"source %T lacks CreateBatch; use a serverlessspark source\", src)\n}\nerr := tool.ValidateSource(src)","typeGuard":"func isSparkBatchSource(s sources.Source) bool {\n    _, ok := s.(createbatch.CompatibleSource)\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    log.Fatalf(\"create-batch tool mis-bound: %v — fix 'source:' in YAML\", err)\n}","preventionTips":["Dedicate separate source entries per kind (database vs serverlessspark)","Grep YAML for tools referencing sources of the wrong kind before merge","Test config loading in CI so mis-binding fails before deployment"],"tags":["config","type-mismatch","serverlessspark","source-binding"],"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"}