fix(embedding): omit null encoding_format for openai requests#25395
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe to merge — minimal, targeted fix with proper regression coverage. The change is a 3-line removal that corrects a clearly wrong default (sending No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/main.py | Removes 3-line else block that was explicitly setting optional_params["encoding_format"] = None when no encoding format was provided, preventing null values from being forwarded to OpenAI-compatible APIs. |
| tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py | New test file with two mock-based regression tests: one verifying encoding_format is absent from optional_params when unset, another verifying the explicit value is forwarded correctly. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["litellm.embedding(...)"] --> B["get_optional_params_embeddings(encoding_format=...)"]
B --> C{"encoding_format\nprovided?"}
C -- "Yes (e.g. 'float')" --> D["optional_params includes\nencoding_format='float'"]
C -- "No (None)" --> E["optional_params does NOT\ninclude encoding_format"]
D --> F["openai_chat_completions.embedding(optional_params=...)"]
E --> F
F --> G["OpenAI SDK sends request\nwithout null encoding_format"]
Reviews (1): Last reviewed commit: "fix(embedding): omit null encoding_forma..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@yuneng-berri @ishaan-jaff @Sameerlite @krrish-berri-2 Hey! Could you please take a look at this PR when you get a chance? I’d really appreciate your feedback. Thanks! |
e3d160f
into
BerriAI:litellm_oss_staging_04_11_2026
Relevant issues
Fixes #25388
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
✅ Test
Changes
encoding_format: nullin embedding requests when it is not set.encoding_formatvalues (for example,"float").