{"record":{"id":"a1bf8b56b24ff4be","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-a1bf8b","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/bigquery/bigqueryexecutesql/bigqueryexecutesql.go","lineNumber":115,"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\tsql, ok := paramsMap[\"sql\"].(string)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"unable to cast sql parameter %s\", paramsMap[\"sql\"]), nil)\n\t}\n\tdryRun, ok := paramsMap[\"dry_run\"].(bool)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"unable to cast dry_run parameter %s\", paramsMap[\"dry_run\"]), nil)\n\t}","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go#L97-L133","documentation":"ValidateSource for the bigquery-execute-sql tool asserts that the supplied sources.Source implements compatibleSource (the BigQuery source interface). If the type assertion fails, the tool cannot safely operate on the source, so it returns this error instead of proceeding. It is a startup-time sanity check that the tool is bound to a BigQuery source.","triggerScenarios":"Calling ValidateSource with a source that is not a BigQuery compatibleSource — typically because the tool was registered under a source name that maps to a different database kind.","commonSituations":"Misconfigured tools.yaml binding the execute-sql tool to a Postgres/CloudSQL source; refactoring that replaced the BigQuery source with a wrapper type; mixing sources across toolbox instances in tests.","solutions":["Bind the tool to a source of kind bigquery.","If wrapping BigQuery, make the wrapper implement the compatibleSource interface.","Confirm the source name referenced in the tool config exists and is the BigQuery source.","Re-run server startup so the corrected config is picked up."],"exampleFix":"// before\ntools:\n  exec-sql:\n    kind: bigquery-execute-sql\n    source: my-alloydb-source\n// after\ntools:\n  exec-sql:\n    kind: bigquery-execute-sql\n    source: my-bigquery-source","handlingStrategy":"type-guard","validationCode":"func sourceIsBigQuery(s sources.Source) bool { _, ok := s.(interface{ BigQueryWriteMode() string }); return ok }\n// call tool.ValidateSource(src) during wiring and fail fast on error","typeGuard":"func asCompatible(s sources.Source) (compatibleSource, bool) { c, ok := s.(compatibleSource); return c, ok }","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"binding check failed: %w\", err)\n}","preventionTips":["Call ValidateSource at wiring time so mismatches surface before serving.","Keep a one-to-one mapping between tool kind and source kind in configs.","Avoid wrapping sources without forwarding the required interface methods.","Test tool/source bindings with the real source implementations."],"tags":["go","bigquery","type-assertion","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"}