{"record":{"id":"7f8e714c90656c04","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-7f8e71","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/cloudstoragegetobjectmetadata/cloudstoragegetobjectmetadata.go","lineNumber":114,"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":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragegetobjectmetadata/cloudstoragegetobjectmetadata.go#L96-L132","documentation":"cloudstorage-get-object-metadata's ValidateSource fails when the bound source does not implement the tool's compatibleSource interface. Only Cloud Storage sources can back this tool; any other source type triggers this error during server startup.","triggerScenarios":"Type assertion `source.(compatibleSource)` fails in ValidateSource because the tool's `source` config points at a non-cloudstorage source.","commonSituations":"Miswired YAML binding a GCS object tool to a database source; shared config files with mismatched source names; refactors that changed source kinds.","solutions":["Point `source:` at a cloudstorage source entry.","Remove the tool from sources that cannot support it.","Cross-check tool-to-source bindings in the config before startup."],"exampleFix":"# before\nsource: my-mysql\n# after\nsource: my-gcs","handlingStrategy":"validation","validationCode":"if _, ok := src.(compatibleSource); !ok {\n    return fmt.Errorf(\"get-object-metadata requires a cloudstorage source, got %T\", src)\n}","typeGuard":"func isCompatible(s sources.Source) bool { _, ok := s.(compatibleSource); return ok }","tryCatchPattern":null,"preventionTips":["Bind object tools only to cloudstorage sources","Cross-check tool/source bindings during config review","Validate full config at startup before serving"],"tags":["go","cloudstorage","source-type-mismatch"],"backgroundTag":"source-type-mismatch","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"}