Repository navigation
fix(fireworks_ai): restore Content-Type application/json header (fixes 415) - #33929
Conversation
…ronment Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR restores the
Confidence Score: 5/5The change is a minimal two-line addition isolated to the Fireworks provider with no effect on any other path. The case-insensitive content-type check is correct, the fix applies correctly to all three FireworksAIMixin subclasses, and the two new tests cover both injection and preservation paths without weakening existing coverage. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/fireworks_ai/common_utils.py | Adds Content-Type: application/json default to FireworksAIMixin.validate_environment when the caller has not already set one; correctly uses a case-insensitive key scan so explicit overrides are preserved. |
| tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py | Adds two new mock-only unit tests: one verifying the default Content-Type: application/json header is injected, and one verifying a caller-supplied content-type is not overwritten; no network calls are made. |
Reviews (1): Last reviewed commit: "fix(fireworks_ai): set Content-Type appl..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Confirmed that this works ✅ can we get this in in a RC? |
…PTConfig Instead of re-adding the JSON Content-Type default inside FireworksAIMixin, FireworksAIConfig now delegates header construction to OpenAIGPTConfig and only layers the Fireworks-specific x-session-affinity header on top, so the Content-Type default can no longer drift away from the OpenAI base and reintroduce the 415. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…_environment Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
yes @Thijmen cc: @yuneng-berri |
…eworks_ct chore(release): backport #33929 to rc/1.94.0
…s 415) (BerriAI#33929) * fix(fireworks_ai): set Content-Type application/json in validate_environment Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(fireworks_ai): delegate chat validate_environment to OpenAIGPTConfig Instead of re-adding the JSON Content-Type default inside FireworksAIMixin, FireworksAIConfig now delegates header construction to OpenAIGPTConfig and only layers the Fireworks-specific x-session-affinity header on top, so the Content-Type default can no longer drift away from the OpenAI base and reintroduce the 415. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(fireworks_ai): cover missing api key error path in chat validate_environment Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Krrish Dholakia <krrishdholakia@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 3fcd19d)
Relevant issues
Regression from #33717 (commit b3d05bd, "feat(fireworks_ai): map litellm session id to x-session-affinity header for prompt caching"). Fireworks chat requests started failing with
415 Unsupported Media TypeLinear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Live Fireworks calls through
litellm.completion(real API, no mocks)Before the fix, at commit
82c3313083with the newContent-Typeline removed to recreate the pre-#33717 header behavior:After the fix, at commit
82c3313083:The scripts call
model="fireworks_ai/accounts/fireworks/models/gpt-oss-120b"(andkimi-k2p6) with a short user messageType
🐛 Bug Fix
🧹 Refactoring
Changes
#33717changedFireworksAIConfigfromclass FireworksAIConfig(OpenAIGPTConfig)toclass FireworksAIConfig(FireworksAIMixin, OpenAIGPTConfig). Putting the mixin first in the MRO was deliberate; that is how chat requests pick up the newx-session-affinityheader, which lives inFireworksAIMixin.validate_environment. If the mixin were placed afterOpenAIGPTConfig, the parentvalidate_environmentwould win and the session-affinity header would never be set. The problem is that the two implementations were not equivalent: the parent sets a defaultContent-Type: application/json, the mixin did not. Flipping precedence to the mixin silently dropped that default, and since the body is posted as a pre-serialized string viadata=json.dumps(data), httpx never re-adds it, so Fireworks rejects the body asapplication/octet-streamand returns 415Rather than duplicating the
Content-Typedefault inside the mixin (which would leave two copies free to drift apart again),FireworksAIConfignow owns itsvalidate_environment: it resolves the Fireworks API key, delegates header construction toOpenAIGPTConfig.validate_environment, then layers only the Fireworks-specificx-session-affinityheader on top. TheContent-Typedefault now comes from the OpenAI base and can no longer driftThe mixin keeps a self-contained
validate_environment(Authorization +Content-Typedefault + session affinity) for the text-completion config, whose base does not provide a workingvalidate_environment; the session-affinity logic is shared through the new_add_session_affinity_headerhelper. The rerank config was already overridingvalidate_environmentwith its own JSON headers, so it is unaffectedFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/fbf309f4b50246be91aac926083df16b
Requested by: @krrish-berri-2