{"record":{"id":"fe829b527f7df359","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com","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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go","lineNumber":101,"sourceCode":"}\n\n// Tool represents the create-cluster 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\tproject, ok := paramsMap[\"project\"].(string)\n\tif !ok || project == \"\" {\n\t\treturn nil, util.NewAgentError(\"invalid or missing 'project' parameter; expected a non-empty string\", nil)\n\t}\n\n\tlocation, ok := paramsMap[\"location\"].(string)\n\tif !ok {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go#L83-L119","documentation":"ValidateSource for the alloydb-alloydbcreatecluster tool asserts the injected sources.Source implements the tool's compatibleSource interface (an AlloyDB admin source with UseClientAuthorization and GetDefaultProject). A source of any other kind fails the assertion and this error is returned, blocking the tool from running against an incompatible source.","triggerScenarios":"Configuring the alloydb-alloydbcreatecluster tool with a `source` entry whose kind is not the AlloyDB admin source (e.g. postgres or alloydb-postgres); assertion runs at startup validation or during tool registration.","commonSituations":"Copy-pasted YAML where `source:` points at a SQL source; renamed/restructured config entries; mixing alloydb-postgres and alloydb admin sources in one config.","solutions":["Set the tool's `source` field to an AlloyDB admin source (kind: alloydb)","Verify the referenced source in the `sources:` block declares the correct kind","Restart the toolbox and confirm the tool registers without error"],"exampleFix":"// before\ntools:\n  create-cluster:\n    kind: alloydb-alloydbcreatecluster\n    source: my-postgres-source\n// after\ntools:\n  create-cluster:\n    kind: alloydb-alloydbcreatecluster\n    source: my-alloydb-admin-source","handlingStrategy":"validation","validationCode":"// config sanity check before startup\nsrc, ok := sources[toolCfg.Source]\nif !ok || src.SourceType() != \"alloydb\" {\n  return fmt.Errorf(\"tool %q requires an alloydb admin source, got %T\", toolCfg.Name, src)\n}","typeGuard":"func asCompatibleSource(s sources.Source) (compatibleSource, bool) {\n  cs, ok := s.(compatibleSource)\n  return cs, ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n  log.Fatalf(\"tool misconfigured: %v\", err)\n}","preventionTips":["Match each admin tool's source to a kind: alloydb source","Validate config at startup before serving traffic","Use source names descriptive of their kind"],"tags":["alloydb","tool-config","source-mismatch","go"],"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"}