{"record":{"id":"a53a9c9f5a4e8588","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-a53a9c","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/spanner/spannerexecutesql/spannerexecutesql.go","lineNumber":132,"sourceCode":"\tresp, err := source.RunSQL(ctx, t.Cfg.ReadOnly, sql, nil)\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":114,"sourceCodeEnd":136,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/spanner/spannerexecutesql/spannerexecutesql.go#L114-L136","documentation":"Tool.ValidateSource in spanner-execute-sql type-asserts the source to compatibleSource (SpannerClient, DatabaseDialect, RunSQL). A source of any other type fails the assertion and produces this error during config validation.","triggerScenarios":"ValidateSource receives a non-Spanner source while validating a spanner-execute-sql tool — e.g. the tool's `source:` field references a postgres or mysql source.","commonSituations":"Wrong `source:` reference in tools.yaml; sources renamed/swapped during refactors; reusing a prebuilt spanner config against a different database kind.","solutions":["Point the tool's `source:` at a source defined with kind spanner (or alloydb-spanner-compatible).","Verify the source name exists in the `sources:` section and is of the Spanner type.","When building tools in code, pass the concrete Spanner source to ValidateSource."],"exampleFix":"// before\nexecute-sql:\n  kind: spanner-execute-sql\n  source: my-postgres\n// after\nexecute-sql:\n  kind: spanner-execute-sql\n  source: my-spanner","handlingStrategy":"type-guard","validationCode":"if _, ok := source.(compatibleSource); !ok {\n\treturn errors.New(\"spanner-execute-sql requires a Spanner source\")\n}","typeGuard":"func toSpannerSource(s sources.Source) (compatibleSource, error) {\n\tif cs, ok := s.(compatibleSource); ok {\n\t\treturn cs, nil\n\t}\n\treturn nil, fmt.Errorf(\"%T is not a spanner compatibleSource\", s)\n}","tryCatchPattern":null,"preventionTips":["Bind spanner tools only to `kind: spanner` sources.","Review diffs of tools.yaml when renaming sources.","Run `toolbox` against the config locally before deploying."],"tags":["go","spanner","config","source-validation"],"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"}