Skip to content

Revert "fix(embedding): omit null encoding_format for openai requests" - #25698

Merged
Sameerlite merged 1 commit into
litellm_oss_staging_04_11_2026from
revert-25395-fix/25388-embedding-encoding-format
Apr 14, 2026
Merged

Revert "fix(embedding): omit null encoding_format for openai requests"#25698
Sameerlite merged 1 commit into
litellm_oss_staging_04_11_2026from
revert-25395-fix/25388-embedding-encoding-format

Conversation

@Sameerlite

Copy link
Copy Markdown
Contributor

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

@Sameerlite
Sameerlite merged commit 3d567c3 into litellm_oss_staging_04_11_2026 Apr 14, 2026
3 of 5 checks passed
@Sameerlite
Sameerlite deleted the revert-25395-fix/25388-embedding-encoding-format branch April 14, 2026 15:07
@vercel

vercel Bot commented Apr 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Building Building Preview, Comment Apr 14, 2026 3:07pm

Request Review

@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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 "float" encoding format into calls that should have been format-neutral, breaking providers that don't support the parameter. The code change in main.py is correct — restoring the explicit optional_params["encoding_format"] = None in the OpenAI provider path prevents the SDK from silently adding its default.

  • The test file test_openai_embeddings_encoding_format.py is deleted without a replacement, leaving the reverted behavior fully untested. The encoding_format=None → SDK behavior is non-obvious and easy to regress; a mock unit test asserting "encoding_format": None is present in optional_params before the SDK call should be added.

Confidence Score: 4/5

  • The code revert is correct, but the deletion of the only test for this behavior leaves a regression risk that should be addressed before merge.
  • The main.py change correctly restores the encoding_format=None guard for the OpenAI provider path and fixes the regression introduced by fix(embedding): omit null encoding_format for openai requests #25395. However, the accompanying test file is deleted without a replacement, which violates the project's test coverage guidelines and leaves the behavior unprotected against future regressions. This warrants a 4/5 until a replacement test is added.
  • tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py — needs a replacement mock test verifying the encoding_format=None behavior in the OpenAI path.

Important Files Changed

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
Loading

Comments Outside Diff (1)

  1. tests/test_litellm/llms/openai/embeddings/test_openai_embeddings_encoding_format.py

    P1 Test 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"] = None to 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:

    1. When encoding_format=None, the key is still present in optional_params before the SDK call (i.e., "encoding_format": None).
    2. 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)

Reviews (1): Last reviewed commit: "Revert "fix(embedding): omit null encodi..." | Re-trigger Greptile

Comment thread litellm/main.py
Comment on lines 4914 to +4918
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Comment typo: "Omiting" → "Omitting"

The inline comment has a spelling error that will be seen by every future reader of this block.

Suggested change
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

fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…embedding-encoding-format

Revert "fix(embedding): omit null encoding_format for openai requests"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant