{"record":{"id":"9d1a0487a578843c","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-9d1a04","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/cloudloggingadmin/cloudloggingadminlistlognames/cloudloggingadminlistlognames.go","lineNumber":124,"sourceCode":"\tvar err error\n\tif source.UseClientAuthorization() {\n\t\ttokenString, err = accessToken.ParseBearerToken()\n\t\tif err != nil {\n\t\t\treturn nil, util.NewClientServerError(\"failed to parse access token\", http.StatusUnauthorized, err)\n\t\t}\n\t}\n\n\tresp, err := source.ListLogNames(ctx, limit, tokenString)\n\tif err != nil {\n\t\treturn nil, util.ProcessGcpError(err)\n\t}\n\treturn resp, nil\n}\n\nfunc (t Tool) RequiresClientAuthorization(source sources.Source) (bool, error) {\n\ts, ok := source.(compatibleSource)\n\tif !ok {\n\t\treturn false, fmt.Errorf(\"invalid source for %q tool: source %q is not a compatible type\", t.Cfg.Type, t.Cfg.Source)\n\t}\n\treturn s.UseClientAuthorization(), 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","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudloggingadmin/cloudloggingadminlistlognames/cloudloggingadminlistlognames.go#L106-L142","documentation":"For cloudloggingadmin-list-log-names, RequiresClientAuthorization asserts the resolved source implements compatibleSource so it can report whether client-side (per-request) OAuth is used. A source of any other kind fails the assertion and produces this error, blocking tool setup.","triggerScenarios":"The tool config's `source` points to a source whose kind is not cloudloggingadmin (e.g. a postgres or cloudhealthcare source), and RequiresClientAuthorization(source) is invoked during server initialization or request handling.","commonSituations":"Reusing a tool YAML entry across projects where the source kind changed; leaving a stale source reference after migrating to Cloud Logging; tests injecting a generic sources.Source stub.","solutions":["Point the tool's `source` field at a source of kind cloudloggingadmin.","Confirm the referenced source exists in the `sources:` section and initialized successfully.","In tests, use a stub implementing compatibleSource (UseClientAuthorization).","Grep the config for the tool and validate its source mapping against the source kind."],"exampleFix":"// before\ntools:\n  list-log-names:\n    kind: cloudloggingadmin-list-log-names\n    source: my-postgres\n// after\ntools:\n  list-log-names:\n    kind: cloudloggingadmin-list-log-names\n    source: my-cloud-logging","handlingStrategy":"validation","validationCode":"for name, t in tools.items():\n    if t['kind'].startswith('cloudloggingadmin') and sources[t['source']]['kind'] != 'cloudloggingadmin':\n        raise ValueError(f\"tool {name}: source {t['source']} must be kind cloudloggingadmin\")","typeGuard":"func mustCompatibleLoggingSource(s sources.Source) (compatibleSource, error) {\n    cs, ok := s.(compatibleSource)\n    if !ok { return nil, fmt.Errorf(\"source %T incompatible with cloudloggingadmin tools\", s) }\n    return cs, nil\n}","tryCatchPattern":null,"preventionTips":["Pair each Cloud Logging tool with a cloudloggingadmin-kind source","Review tool-to-source mappings after any source kind migration","Add startup assertions validating source kind per tool kind","Use distinct source names that encode the kind (e.g. logging-admin-src)"],"tags":["go","config","source-compatibility","cloud-logging"],"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"}