fix: preserve composite video content routing

This commit is contained in:
Heatherm Huang
2026-07-23 09:26:43 +08:00
parent cb81e17fea
commit ca6b192728
2 changed files with 14 additions and 4 deletions
+4 -1
View File
@@ -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
}
+10 -3
View File
@@ -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")
}
}