{"record":{"id":"d1c50f27baa42623","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-d1c50f","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/cloudstorage/cloudstoragereadobject/cloudstoragereadobject.go","lineNumber":117,"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\tbucket := cloudstoragecommon.ResolveString(t.Cfg.Bucket, mapParams, bucketKey)\n\tif bucket == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", bucketKey), nil)\n\t}\n\tobject, ok := mapParams[objectKey].(string)\n\tif !ok || object == \"\" {\n\t\treturn nil, util.NewAgentError(fmt.Sprintf(\"invalid or missing '%s' parameter; expected a non-empty string\", objectKey), nil)\n\t}","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragereadobject/cloudstoragereadobject.go#L99-L135","documentation":"Thrown by cloudstorage-read-object ValidateSource when the source passed to the tool does not implement its compatibleSource interface. This tool requires a Cloud Storage source; any other source type fails the assertion.","triggerScenarios":"Tool config's `source:` points at a non-cloud-storage source; ValidateSource invoked with a wrong sources.Source implementation in tests or code.","commonSituations":"Copy-pasted tool YAML retaining another source's name; renamed sources leaving stale references; wiring tools to database sources by mistake.","solutions":["Point the tool's `source` at a cloud-storage kind source","Ensure the source name exists in the sources section of tools.yaml","Reload the server so validation runs against the corrected config"],"exampleFix":"// before\n  read-object:\n    kind: cloudstorage-read-object\n    source: my-alloydb\n// after\n  read-object:\n    kind: cloudstorage-read-object\n    source: my-gcs","handlingStrategy":"type-guard","validationCode":"if kind := sourceKinds[cfg.Source]; kind != \"cloud-storage\" {\n    return fmt.Errorf(\"read-object needs a cloud-storage source; %q is %s\", cfg.Source, kind)\n}","typeGuard":"func toCloudStorageSource(s sources.Source) (sources.Source, bool) {\n    if cs, ok := s.(compatibleSource); ok {\n        return cs, true\n    }\n    return nil, false\n}","tryCatchPattern":null,"preventionTips":["Map each tool kind to its allowed source kinds and validate pairs at startup","Avoid copy-pasting tool blocks without updating source","Run `toolbox validate` style checks in CI"],"tags":["go","configuration","type-mismatch","cloud-storage"],"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"}