{"record":{"id":"219e509c8d3ad7df","repo":"googleapis/mcp-toolbox","slug":"invalid-source-for-q-tool-source-q-is-not-a-com-219e50","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/cloudstoragedeleteobject/cloudstoragedeleteobject.go","lineNumber":111,"sourceCode":"\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":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragedeleteobject/cloudstoragedeleteobject.go#L93-L129","documentation":"Tool.ValidateSource for cloudstorage-delete-object fails when the bound source does not implement the tool's compatibleSource interface. This guards Invoke, which type-asserts the source to obtain the Cloud Storage client.","triggerScenarios":"tools.yaml binds cloudstorage-delete-object to a source of a non-cloudstorage kind (or a cloudstorage source missing the required client interface), causing the type assertion to fail during tool/source validation.","commonSituations":"Wrong source name in the tool config; source kind changed after a refactor; reusing a shared tools.yaml across projects with different source definitions.","solutions":["Point the tool's source field at a cloudstorage source","Confirm the source initializes successfully (client creation) before tool validation","Regenerate/validate the toolbox config with `toolbox` startup to catch mismatches early"],"exampleFix":"// before\ntools:\n  delete-object:\n    kind: cloudstorage-delete-object\n    source: my-postgres\n// after\ntools:\n  delete-object:\n    kind: cloudstorage-delete-object\n    source: my-gcs","handlingStrategy":"type-guard","validationCode":"if _, ok := sources[toolCfg.Source].(cloudstorage.Source); !ok {\n    log.Fatalf(\"delete-object tool must bind a cloudstorage source\")\n}","typeGuard":"func isGCSCompatible(s sources.Source) bool {\n    _, ok := s.(cloudstorage.CompatibleSource)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Match tool kind to source kind","Validate configs at startup, not at request time","Avoid renaming sources without updating tool references"],"tags":["go","mcp-toolbox","configuration","source-mismatch"],"backgroundTag":"incompatible-tool-source","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"}