Skip to content

fix(embedding): omit null encoding_format for openai requests#25395

Merged
krrish-berri-2 merged 1 commit intoBerriAI:litellm_oss_staging_04_11_2026from
meutsabdahal:fix/25388-embedding-encoding-format
Apr 12, 2026
Merged

fix(embedding): omit null encoding_format for openai requests#25395
krrish-berri-2 merged 1 commit intoBerriAI:litellm_oss_staging_04_11_2026from
meutsabdahal:fix/25388-embedding-encoding-format

Conversation

@meutsabdahal
Copy link
Copy Markdown
Contributor

@meutsabdahal meutsabdahal commented Apr 9, 2026

Relevant issues

Fixes #25388

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays 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)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix
✅ Test

Changes

  • Stop sending encoding_format: null in embedding requests when it is not set.
  • Preserve explicit encoding_format values (for example, "float").
  • Add regression tests for both behaviors (unset omitted, explicit preserved).

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 9, 2026 4:20am

Request Review

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing meutsabdahal:fix/25388-embedding-encoding-format (91e7570) with main (6e6f5be)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR fixes a bug where encoding_format: null was being sent to OpenAI-compatible embedding APIs when the parameter was not explicitly provided, by removing the else branch that set optional_params["encoding_format"] = None. Two regression tests are added that mock openai_chat_completions.embedding to verify the parameter is absent when unset and present when explicitly supplied.

Confidence Score: 5/5

Safe to merge — minimal, targeted fix with proper regression coverage.

The change is a 3-line removal that corrects a clearly wrong default (sending null to an API that doesn't expect it). Tests are mock-based (no real network calls), cover both the unset and explicit cases, and live in the correct test directory. No other concerns were identified.

No files require special attention.

Vulnerabilities

No security concerns identified.

Important Files Changed

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"]
Loading

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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@meutsabdahal
Copy link
Copy Markdown
Contributor Author

meutsabdahal commented Apr 10, 2026

@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!

@krrish-berri-2 krrish-berri-2 changed the base branch from main to litellm_oss_staging_04_11_2026 April 12, 2026 02:39
@krrish-berri-2 krrish-berri-2 merged commit e3d160f into BerriAI:litellm_oss_staging_04_11_2026 Apr 12, 2026
49 of 51 checks passed
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.

[Bug] LiteLLM sends encoding_format: None causing Gitee AI and SiliconFlow API errors

2 participants