Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-9433: fix(composio): preserve empty tool arguments (#10763)
Multica Eve0e3b2f204cf1
diff --git a/server/internal/integrations/composio/team_test.go b/server/internal/integrations/composio/team_test.goindex 8daab11858..8fcc779934 100644--- a/server/internal/integrations/composio/team_test.go+++ b/server/internal/integrations/composio/team_test.go@@ -85,3 +85,30 @@ func TestExecuteTool_RequiresConnectionIdentity(t *testing.T) {t.Fatalf("incomplete identity reached upstream %d times", calls.Load())}}++func TestExecuteTool_EmptyArgumentsOnWire(t *testing.T) {+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ var wire map[string]json.RawMessage+ if err := json.NewDecoder(r.Body).Decode(&wire); err != nil {+ t.Error(err)+ }+ if got := string(wire["arguments"]); got != `{}` {+ t.Errorf("arguments on wire = %q, want {}; body = %s", got, wire)+ }+ w.Header().Set("Content-Type", "application/json")+ _, _ = w.Write([]byte(`{"successful":true,"data":{"accountSummaries":[]}}`))+ }))+ defer srv.Close()+ client, err := sdk.NewClient(sdk.Options{APIKey: "test-key", BaseURL: srv.URL, Timeout: time.Second})+ if err != nil {+ t.Fatal(err)+ }+ svc := newTestService(t, client, newFakeStore())+ resp, err := svc.ExecuteTool(context.Background(), "ca_selected", "ws_team", sdk.Tool{Slug: "GOOGLE_ANALYTICS_LIST_ACCOUNT_SUMMARIES"}, map[string]any{})+ if err != nil {+ t.Fatal(err)+ }+ if !resp.Successful {+ t.Errorf("unexpected response: %+v", resp)+ }+}diff --git a/server/pkg/composio/client_test.go b/server/pkg/composio/client_test.goindex 93feeb906d..1f507dadba 100644--- a/server/pkg/composio/client_test.go+++ b/server/pkg/composio/client_test.go@@ -529,6 +529,44 @@ func TestExecuteTool_Success(t *testing.T) {}}+func TestExecuteTool_ArgumentsOnWire(t *testing.T) {+ for _, tt := range []struct {+ name string+ args map[string]any+ want string+ }{+ {name: "empty", args: map[string]any{}, want: `{}`},+ {name: "nil", want: `{}`},+ {name: "nonempty", args: map[string]any{"pageSize": 1}, want: `{"pageSize":1}`},+ } {+ t.Run(tt.name, func(t *testing.T) {+ c, _ := newTestServer(t, func(w http.ResponseWriter, r *http.Request) {+ if r.Method != http.MethodPost || r.URL.Path != "/tools/execute/GOOGLE_ANALYTICS_LIST_ACCOUNT_SUMMARIES" {+ t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path)+ }+ var wire map[string]json.RawMessage+ readJSON(t, r, &wire)+ if got := string(wire["arguments"]); got != tt.want {+ t.Errorf("arguments on wire = %q, want %s; body = %s", got, tt.want, wire)+ }+ writeJSON(t, w, http.StatusOK, map[string]any{"successful": true})+ })+ resp, err := c.ExecuteTool(context.Background(), "GOOGLE_ANALYTICS_LIST_ACCOUNT_SUMMARIES", composio.ExecuteToolRequest{+ Arguments: tt.args,+ ConnectedAccountID: "ca_selected",+ UserID: "ws_team",+ Version: "20261027_00",+ })+ if err != nil {+ t.Fatal(err)+ }+ if !resp.Successful {+ t.Errorf("unexpected response: %+v", resp)+ }+ })+ }+}+// TestExecuteToolRequest_VersionSerialization locks in the json tag for the// Version field — GPT-Boy's review against PR #4603 caught that the field// used to serialize as `toolkit_versions`, which is not a v3.1 wire key.diff --git a/server/pkg/composio/tools.go b/server/pkg/composio/tools.goindex 599411502a..bcfefdc160 100644--- a/server/pkg/composio/tools.go+++ b/server/pkg/composio/tools.go@@ -16,7 +16,8 @@ import (// The SDK leaves provider-specific identity validation to the upstream.type ExecuteToolRequest struct {// Arguments is the structured input to the tool. Shape varies per tool.- Arguments map[string]any `json:"arguments,omitempty"`+ // ExecuteTool sends nil as an empty object.+ Arguments map[string]any `json:"arguments"`// ConnectedAccountID pins execution to a specific connected account.ConnectedAccountID string `json:"connected_account_id,omitempty"`@@ -135,6 +136,9 @@ func (c *Client) ExecuteTool(ctx context.Context, toolSlug string, req ExecuteToif req.ConnectedAccountID == "" && req.UserID == "" {return nil, errors.New("composio: ExecuteTool: either ConnectedAccountID or UserID must be set")}+ if req.Arguments == nil {+ req.Arguments = map[string]any{}+ }var out ExecuteToolResponseif err := c.do(c.newRequest(ctx).SetBody(req),http.MethodPost, "/tools/execute/"+url.PathEscape(toolSlug), &out); err != nil {