Commit graph

35229 commits

Author SHA1 Message Date
Yuneng Jiang
086e6f99b3
chore: fixes 2026-04-04 23:46:39 -07:00
Ishaan Jaffer
97250c55f0 Revert "tmp: add custom version input to publish_enterprise workflow"
This reverts commit 60bb1a2283.
2026-03-13 11:10:46 -07:00
Ishaan Jaffer
60bb1a2283 tmp: add custom version input to publish_enterprise workflow 2026-03-13 11:09:25 -07:00
Ishaan Jaffer
b75f6162ed fix: add complete/completed to primary query not_in; fix vacuous test assertion
- Primary find_many was missing "complete" and "completed" in its not_in
  filter, creating asymmetry with the fallback query. A job whose status
  was set to "complete" but whose batch_processed flag update failed would
  be silently re-fetched and re-processed every cycle, emitting duplicate
  cost logs.

- test_fallback_completion_update_omits_batch_processed patched
  _is_base64_encoded_unified_file_id to return None, causing an immediate
  continue — so update() was never called and the assertion looped over an
  empty list (vacuously true). Rewrote the test to mock the full
  completion pipeline, verify update() is called exactly once, and assert
  batch_processed is absent from the update data.

- Added symmetric test (primary path) proving batch_processed IS included
  when the column exists.

Made-with: Cursor
2026-03-13 09:01:12 -07:00
Ishaan Jaffer
679b3b247e fix: cache _has_batch_processed_column; guard cleanup from aborting poll; narrow fallback except 2026-03-12 18:28:10 -07:00
Ishaan Jaffer
a14b951248 fix: avoid duplicate cost logging in fallback path; guard integer constants against zero/negative values 2026-03-12 18:00:55 -07:00
Ishaan Jaffer
52c0574cc5 fix: scope stale cleanup to file_purpose, fix file_object mocks, add CheckBatchCost tests 2026-03-12 16:34:00 -07:00
Ishaan Jaffer
e7f8cd50d0 fix: exclude stale_expired from batch poll queries; fix update_many assertions in tests 2026-03-12 13:24:40 -07:00
Ishaan Jaffer
5acd8f6c6e docs+test: document new polling env vars, add pagination+stale-cleanup tests 2026-03-12 13:02:01 -07:00
Ishaan Jaffer
b2252b4b2a fix(constants): simplify PROXY_BATCH_POLLING_ENABLED readability 2026-03-12 12:58:07 -07:00
Ishaan Jaffer
1f3d128569 fix(proxy): cap managed-object poll size + expire stale rows + kill-switch flag to prevent OOM/Prisma connection loss 2026-03-12 12:57:40 -07:00
yuneng-jiang
7f0ec1e3d8
Merge pull request #23469 from BerriAI/litellm_extras_mar12
[Infra] Proxy Extras
2026-03-12 12:50:17 -07:00
yuneng-jiang
5ffa6b955e build 2026-03-12 12:49:36 -07:00
yuneng-jiang
3a3fd64fcb bump: version 0.4.55 → 0.4.56 2026-03-12 12:46:47 -07:00
yuneng-jiang
cffb2676a5 bump: version 0.4.54 → 0.4.55 2026-03-12 12:46:46 -07:00
Ishaan Jaff
7697b1c397
fix(sso): direct PKCE token exchange + Redis wiring for multi-instance SSO (#22923)
* fix(sso): add direct PKCE token exchange and Redis cache wiring for multi-instance SSO

When PKCE is enabled, bypass fastapi-sso and perform direct token exchange so
code_verifier is correctly included. Store PKCE verifiers as dict in cache
for proper JSON serialization in Redis. Wire user_api_key_cache to Redis when
available so PKCE verifiers are shared across ECS tasks/pods.

Also adds clearer error messages when PKCE is required but not configured.

* refactor(sso): extract PKCE token exchange into SSOAuthenticationHandler methods

- Move import httpx/jwt to module level (top of file, not inside function)
- Extract inline PKCE token exchange + userinfo logic into two static methods:
  _pkce_token_exchange() and _get_pkce_userinfo()
- get_generic_sso_response PKCE path is now a single method call
- Fix double-logging in except block for non-PKCE errors
- Use %-style log formatting (no f-strings in log calls)

* fix: address greptile review feedback

- Fix access_token missing in PKCE path: read from combined_response directly
  instead of generic_sso.access_token (which is only set by verify_and_process)
- Fix PKCE error hint firing when PKCE is already enabled: only show
  'set GENERIC_CLIENT_USE_PKCE=true' advice when code_verifier was absent
- Fix unguarded KeyError on access_token: check for error field in HTTP 200
  responses before accessing token_response['access_token']
- Fix silent empty userinfo: raise ProxyException when both userinfo endpoint
  and id_token fallback produce no user data
- Fix backward-incompatible Redis wiring: only attach Redis to user_api_key_cache
  when GENERIC_CLIENT_USE_PKCE=true, preserving existing in-memory behaviour

* fix: address second round of greptile review feedback

- Fix PKCE error hint: check env var directly (not code_verifier presence) to
  distinguish 'PKCE not configured' from 'PKCE enabled but cache miss'
- Fix misleading Redis TTL comment in proxy_server.py

* fix: address third round of greptile review feedback

- Fix CRITICAL log firing on every non-PKCE callback: only log when PKCE is enabled
- Remove unused pkce_env_value intermediate variable
- Prefer reusing redis_usage_cache over creating separate RedisCache instance
  (avoids losing advanced connection options like SSL, timeouts, db)

* fix: address fourth round of greptile review feedback

- Strip OAuth token credentials from response_convertor input to prevent
  access_token/id_token appearing in restricted-group error messages
- Reuse single httpx.AsyncClient for both token exchange and userinfo requests
  to avoid a second TCP/TLS handshake per SSO callback
- Revert Redis wiring to user_api_key_cache: PKCE code already uses
  redis_usage_cache directly; wiring would route all API-key lookups through
  Redis unnecessarily. Add startup warning instead when PKCE+Redis mismatch.
- Move _OAUTH_TOKEN_FIELDS to module level

* fix remaining PKCE test assertion for dict-format verifier storage

* sanitize PKCE cache log to not expose verifier content

* address greptile review feedback (greploop iteration 3)

* address greptile review feedback (greploop iteration 4)

* address greptile review feedback (greploop iteration 5)

* simplify _get_pkce_userinfo: remove shared-client complexity, use async with directly

* address greptile review feedback (greploop iteration 6)

* address greptile review feedback (greploop iteration 7)

* address greptile review feedback (greploop iteration 8)

* address greptile review feedback (greploop iteration 9)

* address greptile review feedback (greploop iteration 10)

* address greptile review feedback (greploop iteration 11)

* address greptile review feedback (greploop iteration 12)

* fix misleading comment on user_api_key_cache TTL line

* address greptile review feedback (greploop iteration 13)

* address greptile review feedback (greploop iteration 14)

* address greptile review feedback (greploop iteration 15)

* address greptile review feedback (greploop iteration 16)

* address greptile review feedback (greploop iteration 17)

* address greptile review feedback (greploop iteration 18)

* address greptile review feedback (greploop iteration 19)

* address greptile review feedback (greploop iteration 20)

* address greptile review feedback (greploop iteration 21)

* address greptile review feedback (greploop iteration 22)

* address greptile review feedback (greploop iteration 23)

* address greptile review feedback (greploop iteration 24)

* address greptile review feedback (greploop iteration 25)

* address greptile review feedback (greploop iteration 26)

* address greptile review feedback (greploop iteration 27)

* address greptile review feedback (greploop iteration 28)

* address greptile review feedback (greploop iteration 29)

* address greptile review feedback (greploop iteration 30)

* address greptile review feedback (greploop iteration 31)

* address greptile review feedback (greploop iteration 32)

* address greptile review feedback (greploop iteration 33)

* address greptile review feedback (greploop iteration 34)

* address greptile review feedback (greploop iteration 35)

* address greptile review feedback (greploop iteration 37)

- read GENERIC_CLIENT_USE_PKCE env var once in prepare_token_exchange_parameters
- include actual decode error in jwt.decode failure exception message
- add GENERIC_CLIENT_USE_PKCE=true to no-state regression test

* defer PKCE verifier deletion until after all downstream processing

Move _delete_pkce_verifier to after response_convertor and
process_sso_jwt_access_token complete. If JWT processing raises,
the verifier stays in cache so the user can retry without restarting
the full OAuth flow.

* address greptile review feedback (greploop iteration 38)

- fix strict-mode cache miss error message to differentiate
  cross-instance routing failures (Redis configured) from single-instance
  issues (TTL expiry, pod restart) when only in-memory cache is available
- add comment above _get_pkce_userinfo call explaining that bearer
  credentials are always sourced from token_response in the merge step

* fix null JSON response body in _pkce_token_exchange

- Guard against HTTP 200 with body null: response.json() returns None
  for JSON null, and calling .get() on None raises AttributeError.
  Now raises a clean ProxyException with a clear error message.
- Fix misleading userinfo warning: was always saying "empty dict" but
  also fires for JSON null responses; updated to say "empty or null".
- Add HTTP status code assertion to cache miss test.

* address greptile review feedback (greploop iteration 39)

- fix credential leakage: directly assign received_response from
  combined_response instead of relying on nonlocal mutation; Pyright
  was flagging the old guard as unreachable, meaning credential stripping
  might not execute — now it always runs unconditionally
- add test for legacy plain-string cache format backward compat branch
- add test for HTTP 200 with no error field and no access_token (else branch)
- add test for HTTP 200 with JSON null body (new AttributeError guard)

* fix _OAUTH_TOKEN_FIELDS merge loop to preserve userinfo values on absent fields

When the token endpoint omits a bearer-credential field entirely (field
absent from token_response), the previous code deleted it from merged even
if userinfo provided a valid value. Now:
- non-null in token_response → restore authoritative token endpoint value
- explicit null in token_response → remove key from merged (clean absence)
- field absent from token_response → leave userinfo value unchanged

* use HTTP 401 for PKCE missing config errors

GENERIC_CLIENT_ID and GENERIC_TOKEN_ENDPOINT missing when PKCE is
enabled are auth-flow failures, not server errors. Use 401 instead
of 500 to avoid triggering false-positive server error alerts in
monitoring systems.

* address greptile review feedback (greploop iteration 40)

- fix duplicate error logging: demote first format-error log to DEBUG
  so the detailed ERROR in strict-mode branch is not duplicated
- add HTTP status code assertions to all PKCE ProxyException tests
  for better regression protection against accidental code changes

* add credential absence assertions to test_pkce_token_exchange_basic_auth

Verify that client_id and client_secret are NOT double-sent in the POST
body when Basic Auth is used (include_client_id=False with client_secret).
Catches regressions where credentials leak into both Auth header and body.

* address greptile review feedback (greploop iteration 41)

- add Bearer token header assertion to test_pkce_token_exchange_credentials_in_body
- add cache query assertions to both non-strict mode tests to confirm
  the cache was accessed before the warning path triggers

* address greptile review feedback (greploop iteration 42)

- assert null id_token is absent from merged result in basic auth test
- add test for HTTP 200 empty/null userinfo body with no id_token fallback

* use caplog to verify warning logs in non-strict cache miss tests

The two non-strict mode tests now use pytest's caplog fixture to assert
that a warning is actually emitted, not just that the code continues
without raising. This catches regressions where the warning silently
disappears.

* remove dead-code response=None guard in _pkce_token_exchange

* clean up stale pkce verifier cache entries in non-strict mode

* fix test: configure async_delete_cache as AsyncMock and assert cleanup called

* add sentinel guard so pkce-no-redis warning only fires once across hot-reloads

* fix misleading comments: code_verifier init and bearer-credential merge docs

* add best-effort cleanup in strict-mode for corrupt/empty cache entries

* add redirect_uri assertion, userinfo body in non-200 log, sentinel comment
2026-03-12 12:41:39 -07:00
Cesar Garcia
7ec78232b2
Merge pull request #23440 from BerriAI/litellm_oss_staging_03_11_2026
Litellm oss staging 03 11 2026
2026-03-12 16:24:14 -03:00
Chesars
690ad4c45b fix(openai): drop all reasoning_effort for gpt-5.4 + tools, including 'none'
OpenAI rejects any reasoning_effort (even 'none') with tools in
/v1/chat/completions for gpt-5.4. Update the guard to drop reasoning_effort
regardless of value. Add docs explaining the auto-drop behavior.
2026-03-12 16:22:40 -03:00
Chesars
17dbc61f39 fix(openai): align gpt-5.4 reasoning_effort drop with main
Remove dead routing condition (is_model_gpt_5_4_plus_model) that
prevented reasoning_effort from being dropped when tools are present.
The Responses API routing was never merged, so the guard was a no-op
that broke the drop logic introduced by 14b52b1318 on main.
2026-03-12 16:22:40 -03:00
Cesar Garcia
ec763784e0
Merge branch 'main' into litellm_oss_staging_03_11_2026 2026-03-12 16:21:28 -03:00
Joe Reyna
f2f843448e
Merge pull request #23414 from joereyna/fix/pass-through-server-root-path
fix: strip SERVER_ROOT_PATH prefix before checking mapped pass-through routes
2026-03-12 11:57:13 -07:00
yuneng-jiang
779a231036
Merge pull request #23465 from BerriAI/ui_build_mar12
[Infra[ UI Build + Tests
2026-03-12 11:29:46 -07:00
yuneng-jiang
d17d205963 chore: update Next.js build artifacts (2026-03-12 18:25 UTC, node v22.16.0) 2026-03-12 11:25:05 -07:00
yuneng-jiang
c8ce098b65 fixing tests 2026-03-12 11:24:15 -07:00
yuneng-jiang
68b8b47d58
Merge pull request #23463 from BerriAI/ui_build_mar12
[Infra] Fixing UI Build
2026-03-12 10:54:00 -07:00
yuneng-jiang
e38edb6190 fixing ui build 2026-03-12 10:51:49 -07:00
Chesars
0fc407cfdd ci: exclude enterprise/ from black --check in linting workflow
Contributors don't have local access to enterprise/ files,
so the check would always fail on unformatted enterprise code.
2026-03-12 14:27:00 -03:00
Cesar Garcia
f79744cee2
Merge pull request #18648 from Chesars/fix-black-check-ci
fix: check Black formatting in CI instead of auto-formatting
2026-03-12 14:24:37 -03:00
Chesars
0fcc36c301 style: run black formatter on 52 non-enterprise files
Formats all files flagged by CI except 12 enterprise/ files
which require separate access to format.
2026-03-12 14:23:50 -03:00
Sameer Kankute
3c322a879f
Merge pull request #23460 from BerriAI/litellm_add_webrtc_support
Improve doc for WebRTC
2026-03-12 22:46:23 +05:30
Sameer Kankute
8bbebb5d75 Improve doc for WebRTC 2026-03-12 22:45:36 +05:30
Sameer Kankute
5ccf1cf4fe
Merge pull request #23459 from BerriAI/litellm_add_webrtc_support
Improve doc for WebRTC
2026-03-12 22:43:05 +05:30
Sameer Kankute
cf1d330e63 Improve doc for WebRTC 2026-03-12 22:41:39 +05:30
Cesar Garcia
e01d722803
Merge branch 'main' into litellm_oss_staging_03_11_2026 2026-03-12 13:53:14 -03:00
Sameer Kankute
d507f840d3
Merge pull request #23432 from BerriAI/litellm_azure-model-router-show-actual-model
feat(azure_ai): show actual model used in Azure Model Router response
2026-03-12 22:18:50 +05:30
Sameer Kankute
d1a99f571e
Merge pull request #23446 from BerriAI/litellm_add_webrtc_support
[Feat] Add WebRTC support
2026-03-12 22:16:55 +05:30
Sameer Kankute
507bced04f Fix the live tester 2026-03-12 22:14:08 +05:30
Cesar Garcia
33457ab702
Merge pull request #23457 from Chesars/revert-revert-21601-model-cost-aliases
fix: restore commits lost by revert of PR #21601
2026-03-12 13:43:07 -03:00
Chesars
4e6e1d8de8 merge: resolve conflicts with upstream staging (bedrock + mcp tests)
Keep both sets of tests: upstream's OAuth2 token injection test and
our case-insensitive tool matching tests. Use upstream's version of
the bedrock output_config test (more comprehensive).
2026-03-12 13:40:16 -03:00
Chesars
feed274aa3 Reapply "feat: add model_cost aliases expansion support"
This reverts commit 3d2df7e8b5.
2026-03-12 13:36:57 -03:00
michelligabriele
7c5e2e8389
fix(proxy): make async_post_call_response_headers_hook consistent across all endpoints (#22985)
* fix(proxy): make async_post_call_response_headers_hook consistent across all endpoints

The response headers hook had 5 gaps that prevented callbacks from
reliably extracting routing metadata across endpoint types:

1. Hook never fired for /audio/transcriptions (endpoint bypasses
   base_process_llm_request)
2. custom_llm_provider not accessible in hook data for any endpoint
3. custom_llm_provider not stamped in ResponsesAPIResponse._hidden_params
   (unlike chat completions)
4. model_info under inconsistent keys (metadata vs litellm_metadata)
5. request_headers always None at all call sites

This adds a litellm_call_info parameter to the hook that normalizes
routing metadata (custom_llm_provider, model_info, api_base, model_id)
regardless of endpoint type. Also stamps custom_llm_provider on
Responses API responses, adds the hook call to the transcription
handler, and passes request_headers at all call sites.

Supersedes PR #21385.

* fix(proxy): address review feedback — safer backwards compat and None guards

- Replace try/except TypeError with inspect.signature() check for
  litellm_call_info backwards compatibility. This avoids masking real
  TypeErrors inside callback implementations and prevents double
  invocation with inconsistent parameters.

- Use (data.get("key") or {}) instead of data.get("key", {}) to guard
  against keys that exist with an explicit None value, which would
  cause AttributeError on the subsequent .get() call.

* fix(proxy): cache inspect.signature result for callback compat check

Move the inspect.signature() call into a module-level helper with a
dict cache keyed by callback identity. Avoids repeated introspection
per request per callback in the hot path.

* fix(proxy): use class identity for signature cache key

Key the _CALLBACK_ACCEPTS_CALL_INFO cache by id(type(cb)) instead of
id(cb) to avoid stale entries from Python address reuse after GC.
All instances of the same callback class share the same method
signature, so class identity is both safer and more cache-efficient.
2026-03-12 08:51:00 -07:00
joereyna
1af7f11dae fix: extract normalize_route_for_root_path to deduplicate root-path stripping; fix mock target 2026-03-12 08:16:00 -07:00
joereyna
938452cc59 fix: extract normalize_route_for_root_path to deduplicate root-path stripping 2026-03-12 07:55:22 -07:00
Cesar Garcia
6bd7cd7573
Merge branch 'main' into litellm_oss_staging_03_11_2026 2026-03-12 10:43:08 -03:00
Sameer Kankute
291e6e1841
Merge pull request #23435 from BerriAI/litellm_vector-store-retrieve-list-update-delete
Add vector store retrieve list update delete
2026-03-12 19:08:39 +05:30
Sameer Kankute
4f5b6ae556
Merge pull request #23448 from BerriAI/litellm_cicd_1203126
Litellm cicd 1203126
2026-03-12 19:07:33 +05:30
Sameer Kankute
b7cfcdd35d Add docs 2026-03-12 19:06:57 +05:30
Chesars
fa68d69bcf fix: restore _get_effort_level and is_model_gpt_5_4_plus_model (PR #23151)
Independent fix (base: main) collaterally removed by PR #23276.
Restores:
- _get_effort_level() for extracting effort from string or dict
- is_model_gpt_5_4_plus_model() classmethod
- effective_effort usage in xhigh/tool-drop/sampling/temperature guards
- Azure: _get_effort_level import and usage for dict reasoning_effort
- Azure: gpt-5.4+ tool+reasoning drop logic
2026-03-12 10:28:27 -03:00
Chesars
9d1bcc7d37 Merge upstream/main into litellm_oss_staging_03_11_2026
Restore independent fixes from main that were collaterally removed
when PR #23276 (staging_03_10 → main) carried a revert commit:
- bedrock: restore output_config pop (PR #23240)
- redact_messages: restore dict handling for ModelResponse (PR #23235)
- model_checks: restore list() copies to avoid cache mutation (PR #23236)
- openapi_to_mcp_generator: restore relative URL handling (PR #23238)
- vertex_ai/gemini: restore _LITELLM_INTERNAL_EXTRA_BODY_KEYS check (PR #23131)
- openai types: restore extra finish reasons (PR #22138)
- completion_extras: restore usage transformation logic

Accept main for: model_prices JSONs, credential_endpoints,
team_endpoints, object_permission_utils, responses transformation.
2026-03-12 10:25:13 -03:00
Sameer Kankute
bb451cfcb0 address greptile review feedback (greploop iteration 2)
- Thread api_version through HTTP handlers to Azure realtime endpoints
- Make expires_at optional in RealtimeClientSecretResponse
- Fix test token expiry times to be in the future
- Populate user_id and team_id in minimal_auth for spend tracking

Made-with: Cursor
2026-03-12 18:53:22 +05:30