Skip to content

Commit 217f120

Browse files
test(providers): cover the base_resp stream error path through the iteration wrapper
The stream-iteration wrapper added in 35c95ea routes non-abort iteration errors through handleOpenAIRequestError, so a provider base_resp stream error (MiniMax-style inline error chunk) is now rethrown with the provider-prefix wrap ("TestProvider completion error: ...") instead of the raw message. Adds a focused regression test that yields a chunk carrying base_resp and pins the wrapped message.
1 parent 35c95ea commit 217f120

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/api/providers/__tests__/base-openai-compatible-provider.spec.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,26 @@ describe("BaseOpenAiCompatibleProvider", () => {
368368
expect(result.message.endsWith("aborted")).toBe(true)
369369
})
370370

371+
it("should wrap a non-abort base_resp stream error with the provider prefix through the iteration wrapper", async () => {
372+
mockCreate.mockImplementationOnce(() =>
373+
asyncStreamFrom([
374+
{
375+
choices: [{ delta: { content: "partial" } }],
376+
base_resp: { status_code: 1041, status_msg: "Invalid token" },
377+
},
378+
]),
379+
)
380+
381+
const result = await captureError(
382+
(async () => {
383+
for await (const _ of handler.createMessage("system prompt", [])) {
384+
// consume
385+
}
386+
})(),
387+
)
388+
389+
expect(result.message).toBe("TestProvider completion error: TestProvider API Error (1041): Invalid token")
390+
})
371391
it("should still wrap non-abort request errors with the provider prefix", async () => {
372392
mockCreate.mockImplementationOnce(() => {
373393
throw new Error("boom")

0 commit comments

Comments
 (0)