{"record":{"id":"e53f7bc6aa885654","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-e53f7b","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/cloudloggingadminquerylogs/cloudloggingadminquerylogs.go","lineNumber":182,"sourceCode":"\t\tFilter:      filter,\n\t\tNewestFirst: newestFirst,\n\t\tStartTime:   startTime,\n\t\tEndTime:     endTime,\n\t\tVerbose:     verbose,\n\t\tLimit:       limit,\n\t}\n\n\tresp, err := source.QueryLogs(ctx, queryParams, 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":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudloggingadmin/cloudloggingadminquerylogs/cloudloggingadminquerylogs.go#L164-L200","documentation":"RequiresClientAuthorization for cloudloggingadmin-querylogs asserts the source implements compatibleSource to read UseClientAuthorization(). A source of any other Go type fails the assertion and produces this error, meaning the tool was bound to a non-Cloud Logging Admin source.","triggerScenarios":"Auth resolution during tool invocation or registration when tools.yaml binds querylogs to a database source or a custom source missing UseClientAuthorization().","commonSituations":"Wrong source name in tools.yaml; version upgrades that changed the source interface; custom source wrappers lacking the required method.","solutions":["Point the tool at a cloud-logging-admin-compatible source.","Add UseClientAuthorization() bool to custom source wrappers.","Validate config at startup to surface the mismatch early."],"exampleFix":"// before\n  query-logs:\n    kind: cloud-logging-admin-query-logs\n    source: my-postgres\n// after\n  query-logs:\n    kind: cloud-logging-admin-query-logs\n    source: my-logging-admin","handlingStrategy":"type-guard","validationCode":"// Go: verify the source satisfies the tool's interface before use\nif _, ok := src.(compatibleSource); !ok {\n    return fmt.Errorf(\"query-logs tool requires a cloud-logging-admin source, got %T\", src)\n}","typeGuard":"func asCompatibleSource(s sources.Source) (compatibleSource, bool) {\n    cs, ok := s.(compatibleSource)\n    return cs, ok\n}","tryCatchPattern":"ok, err := tool.RequiresClientAuthorization(src)\nif err != nil {\n    return fmt.Errorf(\"cannot resolve auth mode: %w\", err)\n}","preventionTips":["Compile-time assert custom sources: var _ compatibleSource = (*mySource)(nil).","Validate tool/source kind pairing during config load.","Keep tool bindings and sources sections edited together in the same PR."],"tags":["go","auth","type-assertion","source-compatibility"],"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"}