fix(providers): don't crash on empty choices in openai and deepseek - #6716
fix(providers): don't crash on empty choices in openai and deepseek#6716chiruu12 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6716 +/- ##
===========================================
- Coverage 46.42% 30.46% -15.96%
===========================================
Files 178 101 -77
Lines 18694 11773 -6921
===========================================
- Hits 8679 3587 -5092
+ Misses 10015 8186 -1829 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The |
eca7d6c to
ea3bc8e
Compare
|
Rebased onto current main at ea3bc8e. That cleared the MySQL failure I flagged above: What is left is one red job, Unit tests, integration tests, workflow examples and docs are all green. Could someone re-run the failed job? I cannot trigger it from a fork. |
Fixes #6715.
The OpenAI and DeepSeek providers read
response.choices[0].message.contentwith no guard. An OpenAI-compatible backend can return HTTP 200 with an emptychoiceslist (for example a content-filter block), sochoices[0]raisesIndexErrorand the workflow step crashes.The same fix already landed for litellm/vllm (#6705) and grok (#6710); this covers the two remaining OpenAI-compatible providers.
Change
choices[0]in both providers and degrade to an empty string, matching the grok and litellm behavior._queryreturns{"response": ""}instead of raising.Validation
Both tests pass on this change and fail with
IndexErroron the current code (openai_provider.py:69, deepseek_provider.py:83), so they pin the regression. ruff clean.