{"record":{"id":"4c7ff8d2590df0c0","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-4c7ff8","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/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go","lineNumber":136,"sourceCode":"\t\t\tMessageType:     item.MessageType,\n\t\t\tActionsRequired: item.ActionsRequired,\n\t\t}\n\t}\n\treturn results\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\n// Invoke executes the tool's logic.\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\n\tproject, ok := paramsMap[\"project\"].(string)\n\tif !ok || project == \"\" {\n\t\treturn nil, util.NewAgentError(\"missing or empty 'project' parameter\", nil)\n\t}\n\tinstanceName, ok := paramsMap[\"instance\"].(string)\n\tif !ok || instanceName == \"\" {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go#L118-L154","documentation":"cloudsqlpg-upgrade-precheck asserts the bound source to its compatibleSource interface during ValidateSource. Only Cloud SQL Postgres sources support the pre-check LRO; any other source fails validation with this message before Invoke ever runs.","triggerScenarios":"Tool validation at startup when `source.(compatibleSource)` fails — tool's source field references a non-cloud-sql-postgres source (vanilla postgres, alloydb, etc.).","commonSituations":"Trying to run major-version upgrade pre-checks against a self-managed postgres; copying the tool into a config where the source is a plain database source.","solutions":["Configure the tool with a `cloud-sql-postgres` source (instance under Cloud SQL Admin control)","Verify the source kind and name in the YAML; restart toolbox","Use the Cloud SQL API directly for non-CloudSQL instances — this tool cannot pre-check them"],"exampleFix":"// before\nsources:\n  pg:\n    kind: postgres\ntools:\n  precheck:\n    kind: cloud-sql-pg-upgrade-precheck\n    source: pg\n// after\nsources:\n  pg:\n    kind: cloud-sql-postgres\n    project: my-project\n    instance: my-instance\ntools:\n  precheck:\n    kind: cloud-sql-pg-upgrade-precheck\n    source: pg","handlingStrategy":"validation","validationCode":"if err := tool.ValidateSource(src); err != nil { return fmt.Errorf(\"upgrade-precheck requires a cloud-sql-postgres source: %w\", err) }","typeGuard":"func isPrecheckCapable(s sources.Source) bool { _, ok := s.(interface{ GetDefaultProject() string }); return ok }","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    return nil // skip precheck tool registration rather than crash\n}","preventionTips":["Only register the precheck tool when a cloud-sql-postgres source exists in config","Document in the toolset README which source kinds each admin tool accepts"],"tags":["go","type-assertion","configuration","cloudsql"],"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"}