{"record":{"id":"f525017046e040a6","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-f52501","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/looker/lookerlistgitbranches/lookerlistgitbranches.go","lineNumber":106,"sourceCode":"// validate interface\nvar _ tools.Tool = Tool{}\n\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\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\tsdk, err := source.GetLookerSDK(ctx, string(accessToken))\n\tif err != nil {\n\t\treturn nil, util.NewClientServerError(fmt.Sprintf(\"error getting sdk: %v\", err), http.StatusInternalServerError, err)\n\t}\n\n\tmapParams := params.AsMap()\n\tprojectId := mapParams[\"project_id\"].(string)\n\n\tresp, err := sdk.AllGitBranches(projectId, source.LookerApiSettings())","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/looker/lookerlistgitbranches/lookerlistgitbranches.go#L88-L124","documentation":"The looker-list-gitbranches tool's ValidateSource checks that the supplied sources.Source implements its compatibleSource interface (Looker SDK helpers). A failed type assertion means the tool was bound to a source of the wrong kind, so validation returns this error rather than allowing invocation against an incompatible source.","triggerScenarios":"Calling Tool.ValidateSource(source) where source is not a Looker source — typically because the tool's `source:` references a non-Looker source in tools.yaml, or the wrong Source is passed when composing tools programmatically.","commonSituations":"Tool config pointing at a database source instead of the looker source; duplicated tool definitions with copy-pasted source names; a custom or upgraded Looker source that dropped a required interface method (GetLookerSDK, LookerApiSettings, etc.).","solutions":["Point the tool's `source` field at a source of kind looker in tools.yaml.","Confirm the source name matches an existing entry under `sources` with kind looker.","If using a custom source, implement the full compatibleSource interface."],"exampleFix":"# before\nsources:\n  looker-src:\n    kind: http\ntools:\n  git-branches:\n    kind: looker-list-gitbranches\n    source: looker-src\n\n# after\nsources:\n  looker-src:\n    kind: looker\n    # ...looker auth config...\ntools:\n  git-branches:\n    kind: looker-list-gitbranches\n    source: looker-src","handlingStrategy":"type-guard","validationCode":"// Go: validate the source before use\nif err := tool.ValidateSource(src); err != nil {\n    return fmt.Errorf(\"tool %s bound to incompatible source: %w\", tool.Name(), err)\n}","typeGuard":"func isLookerSource(s sources.Source) bool {\n    _, ok := s.(interface {\n        UseClientAuthorization() bool\n        GetAuthTokenHeaderName() string\n        LookerApiSettings() *rtl.ApiSettings\n        GetLookerSDK(context.Context, string) (*v4.LookerSDK, error)\n    })\n    return ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n    if strings.Contains(err.Error(), \"not a compatible type\") {\n        return fmt.Errorf(\"rebind looker-list-gitbranches to a looker-kind source: %w\", err)\n    }\n    return err\n}","preventionTips":["Pair each looker tool kind with a looker source kind in tools.yaml.","Call ValidateSource at startup for every tool/source pair.","After refactors, re-run integration tests that load real configs.","Avoid sharing one source name across different tool families."],"tags":["go","looker","type-assertion","configuration"],"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"}