From 33d58ed420a25b8a5a7b028cfcd8062f3d8d3f65 Mon Sep 17 00:00:00 2001 From: backryun Date: Tue, 11 Aug 2026 20:48:22 +0900 Subject: [PATCH] fix(types): validate Fal video result URLs (#9989) --- tests/unit/video-fal-grok.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/video-fal-grok.test.ts b/tests/unit/video-fal-grok.test.ts index db0012eff9..51512554b4 100644 --- a/tests/unit/video-fal-grok.test.ts +++ b/tests/unit/video-fal-grok.test.ts @@ -97,3 +97,25 @@ test("handleVideoGeneration rejects Fal video requests without credentials", asy assert.equal(result.status, 401); assert.match(result.error, /Fal API key is required/); }); + +test("handleVideoGeneration rejects malformed Fal video URL payloads", async () => { + const originalFetch = globalThis.fetch; + globalThis.fetch = async () => jsonResponse({ video: { url: { nested: "not-a-url" } } }); + + try { + const result = await handleVideoGeneration({ + body: { + model: "fal-ai/xai/grok-imagine-video/text-to-video", + prompt: "a malformed result", + }, + credentials: { apiKey: "fal-key" }, + log: null, + }); + + assert.equal(result.success, false); + assert.equal(result.status, 502); + assert.match(result.error, /no video URL/); + } finally { + globalThis.fetch = originalFetch; + } +});