Skip to content

fix(providers): don't crash on an empty choices list - #6705

Merged
shahargl merged 1 commit into
keephq:mainfrom
chiruu12:fix/provider-empty-choices
Aug 19, 2026
Merged

fix(providers): don't crash on an empty choices list#6705
shahargl merged 1 commit into
keephq:mainfrom
chiruu12:fix/provider-empty-choices

Conversation

@chiruu12

@chiruu12 chiruu12 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #6706

The litellm and vllm providers read result["choices"][0] inside an except KeyError. An empty choices list raises IndexError, which that handler doesn't catch, so the workflow step dies with an opaque traceback instead of the empty-response fallback the code already has for a missing content key.

This shows up in normal operation. An OpenAI-compatible backend can return HTTP 200 with {"choices": []} (Azure OpenAI does this when a prompt trips its content filter), so raise_for_status() passes and then choices[0] throws.

Catches IndexError alongside KeyError in both providers, so an empty list falls back to "" the same way a missing key does. Added a regression test for the litellm path.

Copilot AI lite review requested due to automatic review settings August 18, 2026 20:37
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. Bug Something isn't working Provider Providers related issues labels Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shahargl shahargl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 19, 2026
@shahargl
shahargl merged commit 1c80d2d into keephq:main Aug 19, 2026
16 of 18 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Well done @chiruu12! Two PRs merged already! 🎉🥳

With your second PR, you're on a roll, and your contributions are already making a difference. 🌟
Looking forward to seeing even more contributions from you. See you in Slack https://slack.keephq.dev 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working lgtm This PR has been approved by a maintainer Provider Providers related issues size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

litellm/vllm providers crash on an empty choices list

3 participants