Repository navigation
fix(streaming): preserve provider status for string error codes - #40645
wzj1228516103 wants to merge 2 commits into
Conversation
Greptile SummaryThis PR prevents nonnumeric provider error codes from masking streaming failures and recovers the HTTP status from the associated response
Confidence Score: 4/5The behavior change appears correct, but the redundant test docstring must be removed to satisfy the repository’s explicit comment policy The status fallback preserves the provider’s HTTP status and message without a demonstrated behavioral regression; only a repository-guideline violation remains Files Needing Attention: tests/test_litellm/test_exception_header_preservation.py
|
| Filename | Overview |
|---|---|
| litellm/exceptions.py | Safely parses provider status values and falls back to the associated HTTP response status |
| tests/test_litellm/test_exception_header_preservation.py | Adds focused regression coverage, but includes a redundant docstring contrary to repository guidance |
Reviews (1): Last reviewed commit: "fix(streaming): preserve provider status..." | Re-trigger Greptile
| assert str(midstream_fallback.response.request.url) == "https://openai.com/v1/" | ||
|
|
||
| def test_midstream_fallback_error_accepts_non_numeric_provider_status(self): | ||
| """Provider error codes can be strings while the response still has an HTTP status.""" |
There was a problem hiding this comment.
This docstring restates the test name, violating the repository requirement that comments only explain genuinely complex logic. Remove it before merging
| """Provider error codes can be strings while the response still has an HTTP status.""" |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
#41528 just merged and edits the same MidStreamFallbackError constructor, so this branch now conflicts. Could you merge main in before review? |
TLDR
Problem this solves:
tool_use_failedas a string error code.int.ValueErrorand hides the provider error.How it solves it:
User Flow
Before: a Groq streaming tool call fails with an internal conversion error.
tool_use_failed.ValueErrorinstead of the provider's tool schema error.After: the same request exposes the provider's HTTP status and error message.
tool_use_failed.400and the original tool validation error.Relevant issues
Fixes #40566
Pre-Submission checklist
Screenshots / Proof of Fix
Before (merge base)
status_code = "tool_use_failed"fails duringMidStreamFallbackErrorconstruction withValueError.After (57debdb)
400.git diff --checkand Python compilation checks pass.Note: the focused pytest command could not run in this environment because the LiteLLM editable build requires the Rust MSVC linker (
link.exe), which is unavailable.Type
🐛 Bug Fix
✅ Test
Caveats
Low
Final Attestation