{"record":{"id":"5f3cdebfff805ec8","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-5f3cde","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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go","lineNumber":142,"sourceCode":"\tresp, err := source.ListBatches(ctx, pageSize, pt, filter)\n\tif err != nil {\n\t\treturn nil, util.ProcessGcpError(err)\n\t}\n\treturn resp, nil\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","sourceCodeStart":124,"sourceCodeEnd":146,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go#L124-L146","documentation":"The serverlessspark-list-batches tool throws this in ValidateSource when its configured source does not implement the tool's `compatibleSource` interface, meaning it is not a Serverless Spark source that can supply a batch admin client. This is a startup-time configuration validation, not a runtime database failure — the tool never executes because its source type is wrong.","triggerScenarios":"A `serverless-spark-list-batches` tool bound via `source:` to a source of any kind other than `serverless-spark`, so the assertion `source.(compatibleSource)` in serverlesssparklistbatches.go fails.","commonSituations":"Bulk-edited tools.yaml where many tools share one wrong source name; environment-specific overlays (staging/prod) replacing the Spark source with another type; forgetting that each tool kind only accepts its matching source kind.","solutions":["Set `source:` to a declared `kind: serverless-spark` source.","Fix the sources block so the referenced source is actually serverless-spark (check `kind` field).","Run `./toolbox --tools-file` validation/dev UI startup locally to catch all incompatible pairings at once."],"exampleFix":"# before\ntools:\n  list-batches:\n    kind: serverless-spark-list-batches\n    source: cloudsql-pg\n# after\ntools:\n  list-batches:\n    kind: serverless-spark-list-batches\n    source: serverless-spark-prod","handlingStrategy":"validation","validationCode":"# ensure the referenced source kind matches\nsources:\n  spark-prod:\n    kind: serverless-spark\ntools:\n  list-batches:\n    kind: serverless-spark-list-batches\n    source: spark-prod","typeGuard":"func isServerlessSparkSource(s sources.Source) bool {\n    _, ok := s.(serverlessspark.Source)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["In multi-environment overlays, re-verify each tool's source after substitution.","Add a lint step that cross-checks tool kinds against source kinds in tools.yaml.","Document the required source kind next to each tool definition."],"tags":["configuration","go","type-mismatch","serverless-spark"],"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"}