From 9a8b7ee7e45ca1dd5b7f761a7b404becddc7741e Mon Sep 17 00:00:00 2001 From: Molecule AI Core-BE Date: Tue, 12 May 2026 11:49:38 +0000 Subject: [PATCH] fix(handlers): pass correct mock-server URL to setupIntegrationRedis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of 5-minute timeout: setupIntegrationRedis seeded Redis with http://bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb (the UUID as hostname), which the Go http.Client cannot resolve. The SSRF validation passes (valid DNS hostname) but DNS resolution fails → HTTP request hangs for the client's default 60s timeout before retrying → test times out at 5m. Fix: change setupIntegrationRedis(t) → setupIntegrationRedis(t, agentURL) so each test passes the actual mock server address (http://127.0.0.1:PORT) before the function caches it. Remove the redundant db.RDB.Set override in Test1 (URL now correct from the start). Co-Authored-By: Claude Opus 4.7 --- .../delegation_executor_integration_test.go | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/workspace-server/internal/handlers/delegation_executor_integration_test.go b/workspace-server/internal/handlers/delegation_executor_integration_test.go index 2360dd72..ac277881 100644 --- a/workspace-server/internal/handlers/delegation_executor_integration_test.go +++ b/workspace-server/internal/handlers/delegation_executor_integration_test.go @@ -113,13 +113,11 @@ func setupIntegrationFixtures(t *testing.T, conn *sql.DB) func() { } // setupIntegrationRedis starts a miniredis, sets db.RDB, and seeds the target -// workspace URL. Returns the miniredis instance for cleanup. -// Idempotent — safe to call in each test regardless of Redis state. -func setupIntegrationRedis(t *testing.T) *miniredis.Miniredis { +// workspace URL to agentURL. Returns the miniredis instance for cleanup. +func setupIntegrationRedis(t *testing.T, agentURL string) *miniredis.Miniredis { t.Helper() mr := setupTestRedis(t) - // Seed the target workspace URL so proxyA2ARequest finds it. - db.CacheURL(context.Background(), testTargetID, "http://"+testTargetID) + db.CacheURL(context.Background(), testTargetID, agentURL) return mr } @@ -182,13 +180,11 @@ func TestIntegration_ExecuteDelegation_DeliveryConfirmedProxyError_TreatsAsSucce // Close immediately — client gets io.EOF on body read }() - // Wire up mocks. - mr := setupIntegrationRedis(t) - defer mr.Close() - - // Override the cached URL with the mock server's actual address. + // Wire up mocks. Agent URL must be known before calling setupIntegrationRedis + // so the correct address is cached in Redis. agentURL := "http://" + ln.Addr().String() - db.RDB.Set(context.Background(), fmt.Sprintf("ws:%s:url", testTargetID), agentURL, 0) + mr := setupIntegrationRedis(t, agentURL) + defer mr.Close() broadcaster := newTestBroadcaster() wh := NewWorkspaceHandler(broadcaster, nil, "http://localhost:8080", t.TempDir()) @@ -380,7 +376,7 @@ func TestIntegration_ExecuteDelegation_CleanProxyResponse_Unchanged(t *testing.T go agentServer.Serve(ln) defer agentServer.Close() - mr := setupIntegrationRedis(t) + mr := setupIntegrationRedis(t, "http://"+ln.Addr().String()) defer mr.Close() broadcaster := newTestBroadcaster()