{"record":{"id":"b04d79a407ce0217","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-b04d79","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/firestore/firestoregetdocuments/firestoregetdocuments.go","lineNumber":103,"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\tmapParams := params.AsMap()\n\tdocumentPathsRaw, ok := mapParams[documentPathsKey].([]any)\n\tif !ok {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected an array\", documentPathsKey), nil)\n\t}\n\n\tif len(documentPathsRaw) == 0 {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"'%s' parameter cannot be empty\", documentPathsKey), nil)\n\t}","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go#L85-L121","documentation":"Same guard as error 1420 but in firestore-get-documents: ValidateSource asserts the supplied source implements compatibleSource. A non-Firestore source fails the assertion and returns this wrapped error before invocation.","triggerScenarios":"Resolving or invoking the tool with a sources.Source whose concrete type is not the Firestore source.","commonSituations":"Config where the tool's source name refers to a non-firestore source; swapping a tool definition to a new source kind without revalidating.","solutions":["Point the tool's `source:` at a firestore-kind source in the config.","Ensure the source is initialized successfully (kind: firestore) before tool creation.","Pass the correct source instance when calling ValidateSource programmatically."],"exampleFix":"// before\nsource: my-sql\ntools:\n  get_docs:\n    kind: firestore-get-documents\n    source: my-sql\n// after\nsources:\n  my-fs:\n    kind: firestore\n    project: my-project\ntools:\n  get_docs:\n    kind: firestore-get-documents\n    source: my-fs","handlingStrategy":"type-guard","validationCode":"if err := tool.ValidateSource(mySource); err != nil {\n\treturn fmt.Errorf(\"firestore-get-documents bound to wrong source: %w\", err)\n}","typeGuard":"func isFirestoreSource(s sources.Source) bool {\n\t_, ok := s.(firestoret.CompatibleSource)\n\treturn ok\n}","tryCatchPattern":"if err := tool.ValidateSource(src); err != nil {\n\treturn fmt.Errorf(\"invalid binding for %s: %w\", toolName, err)\n}","preventionTips":["Bind only firestore-kind sources to firestore tools.","Run startup validation of all tool/source bindings before serving traffic.","Review diffs that change a source's kind while tools still reference it."],"tags":["firestore","source-validation","config"],"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"}