Skip to content

bug: guard against empty choices in Fireworks AI stream chunks#1638

Open
Jwrede wants to merge 1 commit into
Portkey-AI:mainfrom
Jwrede:fix/fireworks-ai-empty-choices
Open

bug: guard against empty choices in Fireworks AI stream chunks#1638
Jwrede wants to merge 1 commit into
Portkey-AI:mainfrom
Jwrede:fix/fireworks-ai-empty-choices

Conversation

@Jwrede
Copy link
Copy Markdown

@Jwrede Jwrede commented May 9, 2026

Summary

Test plan

  • npx jest src/providers/fireworks-ai/chatComplete.test.ts -- all 5 tests pass
  • Prettier formatting passes (npm run format:check)
  • Build succeeds (npm run build via pre-push hook)

Fixes #1627

@narengogi
Copy link
Copy Markdown
Member

@Jwrede please sign your commits

@Jwrede Jwrede force-pushed the fix/fireworks-ai-empty-choices branch from 696217a to 5468210 Compare May 11, 2026 09:23
@Jwrede
Copy link
Copy Markdown
Author

Jwrede commented May 11, 2026

@narengogi Done -- commit is now signed (5468210).

Fireworks AI may send stream chunks with an empty choices array
(e.g. usage-only chunks). Accessing choices[0] on these chunks
caused a runtime crash. Extract choice via optional chaining and
emit an empty choices array when no choice is present.

Fixes Portkey-AI#1627

Signed-off-by: Jonathan Wrede <wrede.jonathan00@gmail.com>
@Jwrede Jwrede force-pushed the fix/fireworks-ai-empty-choices branch from 5468210 to 5912651 Compare May 15, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled exception in fireworks-ai streaming requests when stream chunk has empty choices

2 participants