From ca6b192728f7737530dfeaaa7c1802fb0cdcbaa5 Mon Sep 17 00:00:00 2001 From: Heatherm Huang Date: Thu, 23 Jul 2026 09:26:43 +0800 Subject: [PATCH] fix: preserve composite video content routing --- backend/internal/server/routes/gateway.go | 5 ++++- backend/internal/server/routes/gateway_test.go | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/internal/server/routes/gateway.go b/backend/internal/server/routes/gateway.go index cbf455b45..ee435eca8 100644 --- a/backend/internal/server/routes/gateway.go +++ b/backend/internal/server/routes/gateway.go @@ -122,7 +122,10 @@ func RegisterGatewayRoutes( }) } videoContentHandler := func(c *gin.Context) { - if getGroupPlatform(c) == service.PlatformGrok { + // Video content requests do not carry a model, so composite groups cannot + // be resolved by compositeTargetPlatformMiddleware. Route them through + // the Grok handler just like video status lookups. + if getGroupPlatform(c) == service.PlatformGrok || getGroupPlatform(c) == service.PlatformComposite { h.OpenAIGateway.GrokVideoContent(c) return } diff --git a/backend/internal/server/routes/gateway_test.go b/backend/internal/server/routes/gateway_test.go index c3e871a80..195351f9e 100644 --- a/backend/internal/server/routes/gateway_test.go +++ b/backend/internal/server/routes/gateway_test.go @@ -16,7 +16,12 @@ import ( ) func newGatewayRoutesTestRouter(platform ...string) *gin.Engine { - return newGatewayRoutesTestRouterWithConfig(&config.Config{}, platform...) + return newGatewayRoutesTestRouterWithConfig(&config.Config{ + Gateway: config.GatewayConfig{ + MaxBodySize: 1024 * 1024, + TextMaxBodySize: 1024 * 1024, + }, + }, platform...) } func newGatewayRoutesTestRouterWithConfig(cfg *config.Config, platform ...string) *gin.Engine { @@ -177,18 +182,20 @@ func TestGatewayRoutesGrokImagesAndVideosPathsAreRegistered(t *testing.T) { } } -func TestGatewayRoutesCompositeVideoStatusUsesGrokHandler(t *testing.T) { +func TestGatewayRoutesCompositeVideoLookupsUseGrokHandler(t *testing.T) { router := newGatewayRoutesTestRouter(service.PlatformComposite) for _, path := range []string{ "/v1/videos/request-123", "/videos/request-123", + "/v1/videos/request-123/content", + "/videos/request-123/content", } { req := httptest.NewRequest(http.MethodGet, path, nil) w := httptest.NewRecorder() router.ServeHTTP(w, req) - require.NotEqual(t, http.StatusNotFound, w.Code, "path=%s should hit Grok video status handler", path) + require.NotEqual(t, http.StatusNotFound, w.Code, "path=%s should hit Grok video lookup handler", path) require.NotContains(t, w.Body.String(), "not supported for this platform") } }