Skip to content

Commit 55bbcfd

Browse files
test(gateway): cover vercel-ai-gateway in-stream error fallback message
Adds a case where the in-band error chunk has no message, exercising the default "Vercel AI Gateway stream error" fallback branch flagged as uncovered. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a2a41ec commit 55bbcfd

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/api/providers/__tests__/vercel-ai-gateway.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,23 @@ describe("VercelAiGatewayHandler", () => {
212212
}).rejects.toThrow("Too many requests, please wait before trying again")
213213
})
214214

215+
it("throws a default message when an in-stream error chunk has no message", async () => {
216+
mockCreate.mockImplementation(async () => ({
217+
[Symbol.asyncIterator]: async function* () {
218+
yield { error: {} }
219+
},
220+
}))
221+
222+
const handler = new VercelAiGatewayHandler(mockOptions)
223+
const stream = handler.createMessage("You are a helpful assistant.", [{ role: "user", content: "Hello" }])
224+
225+
await expect(async () => {
226+
for await (const _chunk of stream) {
227+
// drain
228+
}
229+
}).rejects.toThrow("Vercel AI Gateway stream error")
230+
})
231+
215232
it("uses correct temperature from options", async () => {
216233
const customTemp = 0.5
217234
const handler = new VercelAiGatewayHandler({

0 commit comments

Comments
 (0)