fix(types): validate Fal video result URLs (#9989)

This commit is contained in:
backryun
2026-08-11 20:48:22 +09:00
committed by GitHub
parent 861011c02b
commit 33d58ed420

View File

@@ -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;
}
});