Skip to content

Fix/proxy only failure call type#24050

Merged
3 commits merged intoBerriAI:litellm_oss_staging_03_18_2026from
alilxxey:fix/proxy-only-failure-call-type
Mar 19, 2026
Merged

Fix/proxy only failure call type#24050
3 commits merged intoBerriAI:litellm_oss_staging_03_18_2026from
alilxxey:fix/proxy-only-failure-call-type

Conversation

@alilxxey
Copy link
Copy Markdown

Relevant issues

Fixes #24049

Pre-Submission checklist

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

  • I have Added testing in the repository for this change. The regression test was added in tests/proxy_unit_tests/test_proxy_utils.py
  • 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

This PR fixes a proxy logging bug where proxy-only failures can emit a stale route-based call_type such as:

  • "/v1/completions"
  • "/completions"
  • "IGNORE_THIS"

instead of the normalized LiteLLM call type:

  • acompletion
  • atext_completion
  • aembedding

Root cause

ProxyLogging._handle_logging_proxy_only_error() infers the normalized call type from the request body shape:

  • messages -> acompletion
  • prompt -> atext_completion
  • input -> aembedding

However, before this PR it only updated logging_obj.call_type.

standard logging payload is later built from logging_obj.model_call_details, where call_type could still contain the original route-based value. This creates a divergence between:

  • logging_obj.call_type
  • logging_obj.model_call_details["call_type"]

As a result, downstream logging callbacks / integrations can receive the wrong call_type for proxy-only failures.

Fix

When _handle_logging_proxy_only_error() determines a normalized call type, it now updates both:

  • litellm_logging_obj.call_type
  • litellm_logging_obj.model_call_details["call_type"]

This keeps the logging object and the payload source-of-truth in sync.

Test coverage

Added a focused regression test in tests/proxy_unit_tests/test_proxy_utils.py covering:

  • chat completions -> acompletion
  • text completions -> atext_completion
  • embeddings -> aembedding

The test asserts that both:

  • logging_obj.call_type
  • logging_obj.model_call_details["call_type"]

match the normalized value.

Validation performed

Targeted regression tests passed with:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=. poetry run pytest -q -p pytest_asyncio.plugin tests/proxy_unit_tests/test_proxy_utils.py -k 'post_call_failure_hook_auth_error_llm_api_route or handle_logging_proxy_only_error_syncs_normalized_call_type'

Result:

4 passed, 171 deselected

Scope

This PR is intentionally narrow. It does not change how proxy-only failures are classified. It only ensures that once a normalized call_type is inferred, that value is propagated to model_call_details, which is the source used to build the standard logging payload.

github-actions bot and others added 2 commits March 18, 2026 20:33
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 18, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 19, 2026 4:31am

Request Review

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 18, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ krrishdholakia
❌ Alexey
❌ github-actions[bot]


Alexey seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing alilxxey:fix/proxy-only-failure-call-type (71b687e) with main (af8363a)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes a logging inconsistency in ProxyLogging._handle_logging_proxy_only_error() where the normalized call_type (e.g. acompletion, atext_completion, aembedding) was only written to litellm_logging_obj.call_type but not propagated to litellm_logging_obj.model_call_details["call_type"], causing downstream logging callbacks to receive the raw route string (e.g. "/v1/completions" or "IGNORE_THIS") instead of the expected LiteLLM call type.

Key changes:

  • Introduces a normalized_call_type staging variable so the resolved call type is applied atomically to both litellm_logging_obj.call_type and litellm_logging_obj.model_call_details["call_type"] in a single block, keeping the logging object and the standard payload source-of-truth in sync.
  • Adds a parametrized regression test covering all three inference paths (messagesacompletion, promptatext_completion, inputaembedding) that asserts both fields are updated correctly.
  • The fix is intentionally minimal — it does not change error classification logic, only ensures the normalized value is fully propagated.
  • The pass_through guard is preserved correctly: if the original call_type is pass_through, normalized_call_type is never set, so neither field is overwritten and the early-return path still triggers as before.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted bug fix with no backward-compatibility risk.
  • The change is extremely narrow: a single new variable consolidating two assignment statements into one guarded block. The pass_through early-return logic is unaffected. The fix has no impact on the request hot path, introduces no new I/O or DB calls, and is fully covered by a new parametrized regression test that validates both mutated fields across all three call-type inference branches.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/utils.py Adds normalized_call_type variable to consolidate the call-type update into both litellm_logging_obj.call_type and litellm_logging_obj.model_call_details["call_type"], fixing the divergence that caused stale route-based call types in the standard logging payload.
tests/proxy_unit_tests/test_proxy_utils.py Adds a parametrized regression test for all three call types (acompletion, atext_completion, aembedding) that asserts both logging_obj.call_type and logging_obj.model_call_details["call_type"] are normalized correctly; uses mocks to avoid real network calls.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[_handle_logging_proxy_only_error called] --> B{litellm_logging_obj is None?}
    B -- Yes --> C[Create new logging obj via function_setup]
    B -- No --> D[Use existing logging obj]
    C --> D

    D --> E{Request body shape?}
    E -- messages list --> F[input = messages\nnormalized_call_type = acompletion]
    E -- prompt str --> G[input = prompt\nnormalized_call_type = atext_completion]
    E -- input list --> H[input = input\nnormalized_call_type = aembedding]
    E -- none match --> I[normalized_call_type = None]

    F --> J{normalized_call_type != None?}
    G --> J
    H --> J
    I --> J

    J -- Yes --> K["litellm_logging_obj.call_type = normalized_call_type\nlitellm_logging_obj.model_call_details['call_type'] = normalized_call_type\n✅ Both fields in sync"]
    J -- No --> L[Fields unchanged]

    K --> M{call_type == pass_through?}
    L --> M

    M -- Yes --> N[return early — logged via callback loop]
    M -- No --> O[pre_call → async_failure_handler → failure_handler]
Loading

Last reviewed commit: "Merge branch 'litell..."

@ghost ghost changed the base branch from main to litellm_oss_staging_03_18_2026 March 19, 2026 04:28
@ghost ghost merged commit 379ed72 into BerriAI:litellm_oss_staging_03_18_2026 Mar 19, 2026
2 of 3 checks passed
This pull request was closed.
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]: Proxy-only failure logs can emit stale route-based call_type instead of normalized LiteLLM call_type

2 participants