Revert "fix(embedding): omit null encoding_format for openai requests" - #25698
Conversation
3d567c3
into
litellm_oss_staging_04_11_2026
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR reverts #25395 ("fix(embedding): omit null encoding_format for openai requests") because the original fix caused the OpenAI Python SDK to inject its default
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/main.py | Reverts the removal of the else branch that explicitly sets optional_params["encoding_format"] = None for the OpenAI provider path. The logic is correct — it prevents the OpenAI Python SDK from injecting its default "float" value — but the comment has a typo ("Omiting"). |
| tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py | Deleted as part of the revert. No replacement test is provided, leaving the encoding_format=None behavior completely untested and vulnerable to future regressions. |
Sequence Diagram
sequenceDiagram
participant Caller
participant litellm_main as litellm.embedding()
participant get_optional_params as get_optional_params_embeddings()
participant openai_llm as OpenAIChatCompletion.embedding()
participant OpenAI_SDK as OpenAI Python SDK
Caller->>litellm_main: "embedding(model, input, encoding_format=None)"
litellm_main->>get_optional_params: "encoding_format=None (default)"
Note over get_optional_params: None == default → omitted from non_default_params
get_optional_params-->>litellm_main: optional_params (no encoding_format key)
Note over litellm_main: OpenAI provider path (reverted)
litellm_main->>litellm_main: "optional_params["encoding_format"] = None (explicit override)"
litellm_main->>openai_llm: "data = {model, input, encoding_format: None, ...}"
openai_llm->>OpenAI_SDK: "embeddings.create(**data)"
Note over OpenAI_SDK: explicit None prevents SDK from injecting default "float"
OpenAI_SDK-->>openai_llm: EmbeddingResponse
openai_llm-->>litellm_main: EmbeddingResponse
litellm_main-->>Caller: EmbeddingResponse
Comments Outside Diff (1)
-
tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.pyTest file deleted without a replacement
This file is being deleted as part of the revert, leaving zero test coverage for the
encoding_format=None→ OpenAI SDK behavior. The CLAUDE.md guidelines require at least one test when changing functionality, and the custom rule on test coverage requires that tests not be removed in a way that masks regressions.The reverted behavior — explicitly setting
optional_params["encoding_format"] = Noneto prevent the OpenAI SDK from defaulting to"float"— is non-obvious and easy to regress. Consider adding a unit/mock test (this folder is mock-only per project rules) that asserts:- When
encoding_format=None, the key is still present inoptional_paramsbefore the SDK call (i.e.,"encoding_format": None). - When
encoding_format="base64", it is forwarded correctly.
Without a test, the next PR touching this block can unknowingly re-introduce the same regression that prompted fix(embedding): omit null encoding_format for openai requests #25395.
Rule Used: What: Flag any modifications to existing tests and... (source)
- When
Reviews (1): Last reviewed commit: "Revert "fix(embedding): omit null encodi..." | Re-trigger Greptile
| if encoding_format is not None: | ||
| optional_params["encoding_format"] = encoding_format | ||
| else: | ||
| # Omiting causes openai sdk to add default value of "float" | ||
| optional_params["encoding_format"] = None |
There was a problem hiding this comment.
Comment typo: "Omiting" → "Omitting"
The inline comment has a spelling error that will be seen by every future reader of this block.
| if encoding_format is not None: | |
| optional_params["encoding_format"] = encoding_format | |
| else: | |
| # Omiting causes openai sdk to add default value of "float" | |
| optional_params["encoding_format"] = None | |
| if encoding_format is not None: | |
| optional_params["encoding_format"] = encoding_format | |
| else: | |
| # Omitting causes openai sdk to add default value of "float" | |
| optional_params["encoding_format"] = None |
…embedding-encoding-format Revert "fix(embedding): omit null encoding_format for openai requests"
Reverts #25395
This breaks test_encoding_format_none_not_omitted_from_openai_sdk. And even if you remove that line, float gets passed as format in every call to all providers, most of them don't support this, causing errors