{"record":{"id":"ad26ee4fb5e20207","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-ad26ee","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/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go","lineNumber":102,"sourceCode":"}\n\n// Tool represents the create-instances tool.\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\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 {\n\t\treturn nil, util.NewAgentError(\"missing 'project' parameter\", nil)\n\t}\n\tname, ok := paramsMap[\"name\"].(string)\n\tif !ok {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudsqlpg/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go#L84-L120","documentation":"cloudsqlpg-create-instances accepts only Cloud SQL Postgres sources. ValidateSource type-asserts the bound sources.Source to compatibleSource and returns this error when the source is of any other kind, preventing the tool from invoking against an incompatible source.","triggerScenarios":"Tool initialization with `source.(compatibleSource)` failing — tool's `source` points at a non-cloud-sql-postgres source (plain `postgres`, `alloydb`, etc.).","commonSituations":"Reusing an alloydb or vanilla postgres source for instance creation; renaming sources and leaving stale references; prebuilt-config users overriding `source` incorrectly.","solutions":["Point the tool at a `cloud-sql-postgres` source in the config","Confirm the referenced source exists and is of the right kind (`toolbox --tools`)","Use a generic run-sql tool instead if instance management isn't needed"],"exampleFix":"// before\nsource: my-postgres  # kind: postgres\n// after\nsource: my-cloudsql-pg  # kind: cloud-sql-postgres","handlingStrategy":"validation","validationCode":"if err := tool.ValidateSource(cfg.Sources[tool.Source]); err != nil { return fmt.Errorf(\"tool %q misconfigured: %w\", tool.Name, err) }","typeGuard":"func isCloudSQLPgSource(s sources.Source) bool { _, ok := s.(interface{ GetDefaultProject() string }); return ok }","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    // fail config load; do not retry — this is a static config problem\n    return err\n}","preventionTips":["Never point Cloud SQL admin tools at vanilla database sources","Diff tool/source kind pairings when upgrading toolbox versions"],"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"}