fix: scope video dispatch to /v1/videos/sync + capture mask
Review findings: the async POST /v1/videos leg is deliberately NOT dispatched — its poll/download companions carry no model field to route by, so registering creation alone would start unretrievable upstream jobs (a stray OpenAI-videos client now gets a clean 404). And /v1/videos/sync joins captureFieldsByPath (headers only, both directions) so enabling captures doesn't buffer conditioning frames or whole clips through cbor+zstd. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXQxVhXBw8PwFAtsVrXSmj
This commit is contained in:
@@ -348,37 +348,49 @@ func TestServer_VideoRoutesDispatch(t *testing.T) {
|
||||
newStubRouter(nil, ""),
|
||||
)
|
||||
|
||||
// JSON body on /v1/videos.
|
||||
body := strings.NewReader(`{"model":"videogen-model","prompt":"a cat"}`)
|
||||
req := httptest.NewRequest(http.MethodPost, "/v1/videos", body)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
w := httptest.NewRecorder()
|
||||
s.ServeHTTP(w, req)
|
||||
if w.Code != http.StatusOK || w.Body.String() != "video response" {
|
||||
t.Fatalf("/v1/videos: status=%d body=%q", w.Code, w.Body.String())
|
||||
}
|
||||
|
||||
// Multipart form on /v1/videos/sync.
|
||||
var buf bytes.Buffer
|
||||
mw := multipart.NewWriter(&buf)
|
||||
mw.WriteField("model", "videogen-model")
|
||||
mw.WriteField("prompt", "a cat")
|
||||
mw.Close()
|
||||
req = httptest.NewRequest(http.MethodPost, "/v1/videos/sync", &buf)
|
||||
req := httptest.NewRequest(http.MethodPost, "/v1/videos/sync", &buf)
|
||||
req.Header.Set("Content-Type", mw.FormDataContentType())
|
||||
w = httptest.NewRecorder()
|
||||
w := httptest.NewRecorder()
|
||||
s.ServeHTTP(w, req)
|
||||
if w.Code != http.StatusOK || w.Body.String() != "video response" {
|
||||
t.Fatalf("/v1/videos/sync: status=%d body=%q", w.Code, w.Body.String())
|
||||
}
|
||||
|
||||
// Unknown model on a video route still 404s.
|
||||
body = strings.NewReader(`{"model":"nope","prompt":"a cat"}`)
|
||||
req = httptest.NewRequest(http.MethodPost, "/v1/videos", body)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
// JSON bodies dispatch too (extraction is content-type driven).
|
||||
jsonReq := httptest.NewRequest(http.MethodPost, "/v1/videos/sync",
|
||||
strings.NewReader(`{"model":"videogen-model","prompt":"a cat"}`))
|
||||
jsonReq.Header.Set("Content-Type", "application/json")
|
||||
w = httptest.NewRecorder()
|
||||
s.ServeHTTP(w, req)
|
||||
s.ServeHTTP(w, jsonReq)
|
||||
if w.Code != http.StatusOK || w.Body.String() != "video response" {
|
||||
t.Fatalf("/v1/videos/sync json: status=%d body=%q", w.Code, w.Body.String())
|
||||
}
|
||||
|
||||
// Unknown model on the video route still 404s.
|
||||
nopeReq := httptest.NewRequest(http.MethodPost, "/v1/videos/sync",
|
||||
strings.NewReader(`{"model":"nope","prompt":"a cat"}`))
|
||||
nopeReq.Header.Set("Content-Type", "application/json")
|
||||
w = httptest.NewRecorder()
|
||||
s.ServeHTTP(w, nopeReq)
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Fatalf("/v1/videos unknown model: status=%d want 404", w.Code)
|
||||
t.Fatalf("/v1/videos/sync unknown model: status=%d want 404", w.Code)
|
||||
}
|
||||
|
||||
// The async job-creation route is NOT dispatched (no poll routes to
|
||||
// complete the flow) — a stray OpenAI-videos client gets a clean 404
|
||||
// instead of an unretrievable upstream job.
|
||||
asyncReq := httptest.NewRequest(http.MethodPost, "/v1/videos",
|
||||
strings.NewReader(`{"model":"videogen-model","prompt":"a cat"}`))
|
||||
asyncReq.Header.Set("Content-Type", "application/json")
|
||||
w = httptest.NewRecorder()
|
||||
s.ServeHTTP(w, asyncReq)
|
||||
if w.Code != http.StatusNotFound {
|
||||
t.Fatalf("POST /v1/videos: status=%d want 404 (async family not routed)", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user