Commit graph

39980 commits

Author SHA1 Message Date
ryan-crabbe-berri
18c93e0ccd
Merge pull request #25809 from BerriAI/litellm_fix_tool_test_panel_bool_rendering
fix(ui): use antd Select for MCP ToolTestPanel bool inputs
2026-04-15 22:50:57 -07:00
ryan-crabbe-berri
cf4f0516be
Merge pull request #25806 from BerriAI/litellm_fix_guardrail_optional_params_bool_rendering
fix(ui): render guardrail optional_params bool defaults in Select
2026-04-15 22:50:20 -07:00
Ryan Crabbe
96415a5ac2
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix-invalidate-orgs-on-team-mutation 2026-04-15 22:41:38 -07:00
Ryan Crabbe
83095c24c6
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_tool_test_panel_bool_rendering 2026-04-15 22:41:09 -07:00
Ryan Crabbe
bbf204e602
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_guardrail_optional_params_bool_rendering 2026-04-15 22:40:37 -07:00
ryan-crabbe-berri
2dd060b4e4
Merge pull request #25838 from BerriAI/litellm_fix-virtual-key-projected-spend-alert
fix(proxy): fix virtual key projected-spend soft budget alerts
2026-04-15 22:22:33 -07:00
Yuneng Jiang
c8cfc5de21
fix(httpx): set response.request and strip content-encoding in MaskedHTTPStatusError
MaskedHTTPStatusError constructs a new httpx.Response from the original
error. Two bugs surfaced under real HTTP error responses:

1. The new Response was created without request=, so response.request
   raised RuntimeError("The .request property has not been set.") for
   any downstream caller (e.g. exception_mapping_utils) that inspected it.

2. The decoded response bytes were passed together with the original
   Content-Encoding header. On construction httpx tried to decompress
   the already-decoded bytes and raised httpx.DecodingError
   ("Error -3 while decompressing data: incorrect header check").

Set response.request to the masked Request and strip Content-Encoding
(and the now-stale Content-Length) before rebuilding the Response.
URL/message masking is unchanged; the new request carries the already
masked URL.

Also update test_logging_key_masking_gemini: the security commit
25f93bed91 moved Gemini API keys from ?key=... URL params to the
x-goog-api-key header, so api_base no longer contains the key.
2026-04-15 22:03:48 -07:00
Ryan Crabbe
f639769ca9
fix(proxy): use flat soft_budget field for virtual key projected-spend alerts
The projected-spend alert in _update_key_cache read from
existing_spend_obj.litellm_budget_table["soft_budget"], but the nested
dict is never populated for virtual keys (the combined_view SQL maps
budget fields to flat top-level attributes instead). This made the
check dead code — it silently short-circuited on every request, and
when unblocked, crashed update_cache with a Pydantic ValidationError
because _get_projected_spend_over_limit returns a date object but
CallInfo.projected_exceeded_date expects str.

Fixes: read from the flat existing_spend_obj.soft_budget field that IS
populated, and stringify projected_exceeded_date.

Also marks team soft budget email alerts as enterprise in docs.

Closes #20324
2026-04-15 21:38:18 -07:00
Yuneng Jiang
070374d03a
fix(ci): authorize RestrictedPython in liccheck.ini
RestrictedPython (ZPL-2.1, a BSD-style permissive license) was added as
a dependency for the custom_code guardrail sandbox, but the license
checker didn't recognize it. Add to authorized packages list.
2026-04-15 21:20:40 -07:00
Yuneng Jiang
fdeeed6df8
fix(ci): resolve mypy and ruff lint failures
- vertex_ai_context_caching.py: add explicit Optional[str] annotation on
  auth_header so later branches that assign vertex_auth_header (Optional[str])
  type-check against the first branch's dict assignment (which already has
  type: ignore[assignment]).
- path_utils.py: remove unused pathlib.Path import (F401).
- emulated_handler.py: extract _extract_tool_call_fields,
  _resolve_queries_from_args, _execute_file_search_tool_calls, and
  _build_follow_up_input helpers to drop aresponses_with_emulated_file_search
  below ruff's PLR0915 statement limit. Behavior unchanged.
2026-04-15 21:12:51 -07:00
yuneng-jiang
be1b802501
Merge pull request #25834 from stuxf/fix/path-traversal-guardrail-yaml
fix(proxy): add shared path utilities, prevent directory traversal
2026-04-15 21:01:48 -07:00
yuneng-jiang
0c8b83c0a1
Merge pull request #25827 from stuxf/fix/outbound-host-validation
fix(proxy): harden request parameter handling
2026-04-15 20:57:45 -07:00
user
a4faacecaf
style: move import os to module level, fix import ordering 2026-04-16 03:29:55 +00:00
user
a44c4d0f27
style: fix import ordering in prompt_endpoints 2026-04-16 03:26:31 +00:00
user
c2b3b62996
test: add unit tests for path_utils safe_join and safe_filename 2026-04-16 03:25:42 +00:00
user
278e3f4a6b
refactor: harden path utils, move imports to module level
Add null byte rejection to safe_join and safe_filename. Normalize
backslash separators in safe_filename for cross-platform safety.
Include resolved path in ValueError for debugging. Move imports
to module level per project conventions.
2026-04-16 03:15:04 +00:00
user
9691649606
fix(proxy): add shared path utilities, prevent directory traversal
Add safe_join() and safe_filename() in proxy/common_utils/path_utils.py
for constructing filesystem paths from user-controlled inputs. Apply to
guardrail category YAML endpoint and dotprompt file converter.
2026-04-16 03:11:50 +00:00
Chesars
10bd3ff5d6 Fix three bugs introduced by staging PRs
- factory.py: fix _sort_bedrock_assistant_content_blocks to treat
  cachePoint blocks with the same sort key as toolUse so Python's
  stable sort keeps each cachePoint paired with its preceding toolUse
  block (PR #24368)

- responses/transformation.py: remove cyclic import of OpenAIGPT5Config
  inside map_openai_params; add _is_gpt_5_model and
  _supports_reasoning_effort_none static methods that replicate the
  same logic without the import cycle. _is_gpt_5_model now also
  excludes pass-through models from other providers (e.g.
  perplexity/openai/gpt-5.2) that contain 'gpt-5' in their name but
  should not be subject to OpenAI GPT-5 temperature restrictions
  (PR #24371)
2026-04-15 23:29:34 -03:00
Chesars
f82ba6ca6b Resolve remaining merge conflicts with upstream/main
- streaming_iterator.py: adopted main's more defensive version of the
  tool-arg queueing check (.get() instead of [], isinstance guard) —
  same logic, same behavior, lower crash surface
- model_prices_and_context_window.json + backup: combined staging's
  search_context_cost_per_query fields (PR #24372) with main's new
  supports_service_tier field — both are independent additions to the
  same Gemini model entries
- test_streaming_handler.py: kept Azure streaming regression test
  (PR #24354) and added main's two new Gemini legacy vertex
  finish_reason normalization tests
- test_gemini_batch_embeddings.py: kept staging's unsupported-params
  filtering tests (PR #24370) and added main's index/order test
2026-04-15 23:05:03 -03:00
ishaan-berri
0b7335201b
Merge pull request #25699 from BerriAI/litellm_ishaan_april14
Litellm ishaan april14
2026-04-15 19:01:06 -07:00
Chesars
67e4604284 Merge upstream/main into litellm_staging_03_22_2026
Resolved conflicts:
- streaming_handler.py: combined role check (PR #24354, Azure streaming)
  with reasoning_items check (new in main) — both are independent OR
  conditions in is_chunk_non_empty()
- CI/CD: accepted main's versions throughout
  - Redis tests migrated to CircleCI (PR #25354): removed enable-redis
    from GH Actions workflows
  - E2E UI tests restructured (PR #25365): simplified CircleCI job
  - Coverage via Codecov added to all GH Actions unit test workflows
  - Deleted test-litellm-matrix.yml and test-proxy-e2e-azure-batches.yml
    (removed in main)
2026-04-15 22:54:53 -03:00
Ishaan Jaffer
def9c4ec47
chore: merge litellm_internal_staging, resolve uv.lock conflict 2026-04-15 18:51:19 -07:00
Ishaan Jaffer
26136708bb
chore: trigger CI re-evaluation 2026-04-15 18:48:13 -07:00
ishaan-berri
ae2aba0e15
Merge pull request #25622 from Sameerlite/litellm_docs_cost_discrepancy_guide
docs(troubleshoot): cost discrepancy debugging guide
2026-04-15 18:43:15 -07:00
ishaan-berri
a588f76789
Litellm ishaan april15 2 (#25828)
* [Test] Add Azure async chat completion timeout test. WIP

* Capture TTFT for /v1/messages streaming responses

The pass-through streaming path for /v1/messages (Anthropic, Bedrock,
Vertex AI, Azure AI, Minimax) logged completion_start_time only after
the entire stream finished. async_success_handler then fell back to
end_time, making TTFT equal to total duration or null in the UI and
Prometheus.

Record the timestamp of the first chunk in async_sse_wrapper and
propagate it to model_call_details before the logging handler runs,
so gen_ai.response.time_to_first_token reflects the real first-chunk
latency.

Fixes #25598

* [Refactor] Implement timeout resolution logic in completion function

add fetch ``request_timeout`` from litellm_settings

* remove stale test case

* remove extra print statement

* default request timeout value in constants to 600s to match timeout defaults handled in the proxy

* fix request timeout if using default value from constants.py

* update code structure, test cases

* only override if the global timeout sets timeout to 6000s

* update code structure, move hard coded values to const and make the reslve function readable by moving fallback logic to a seperate function

* modify default timeout values, replacing hard coded ones with default values defined

---------

Co-authored-by: harish876 <harishgokul01@gmail.com>
Co-authored-by: Joaquin Hui Gomez <joaquinhuigomez@users.noreply.github.com>
2026-04-15 18:42:23 -07:00
user
47214be317
fix(proxy): harden request parameter handling
Tighten validation of request body parameters in the proxy routing
layer. Use context variables for internal call state management
instead of passing flags through request kwargs. Clean up metadata
handling at the proxy boundary.
2026-04-16 01:38:12 +00:00
Ishaan Jaffer
9977e63e3c
Merge remote-tracking branch 'origin/main' into worktree-foamy-jumping-coral 2026-04-15 18:29:55 -07:00
ishaan-berri
10131374ee
Merge pull request #25813 from BerriAI/litellm_ishaan_april15
Litellm ishaan april15
2026-04-15 18:29:22 -07:00
ishaan-berri
7a6b7ade03
Merge pull request #25807 from BerriAI/litellm_fix_provider_headers_in_logging
fix(logging): preserve provider response headers in StandardLoggingPayload
2026-04-15 18:29:03 -07:00
Ishaan Jaffer
537e72c742
style: black format test_mcp_server.py 2026-04-15 18:19:21 -07:00
Ishaan Jaffer
fcd71e0026
style: black format test_mcp_server_manager.py 2026-04-15 18:19:17 -07:00
Ishaan Jaffer
f768946549
style: black format test_anthropic_common_utils.py 2026-04-15 18:19:12 -07:00
Ishaan Jaffer
9a154a3be7
style: black format test_mcp_sigv4_auth.py 2026-04-15 18:19:08 -07:00
Ishaan Jaffer
c8a0fe193f
style: black format test_unit_test_caching.py 2026-04-15 18:19:04 -07:00
Ishaan Jaffer
93a90a53be
style: black format test_mcp_client.py 2026-04-15 18:19:01 -07:00
Ishaan Jaffer
f2a1dbe7c9
style: black format test_health_check_max_tokens.py 2026-04-15 18:18:56 -07:00
Ishaan Jaffer
3847a59d79
style: black format test_model_param_helper.py 2026-04-15 18:18:52 -07:00
Ishaan Jaffer
13952b0b1b
style: black format types/mcp_server/mcp_server_manager.py 2026-04-15 18:18:48 -07:00
Ishaan Jaffer
107003a713
style: black format model_param_helper.py 2026-04-15 18:18:45 -07:00
Ishaan Jaffer
e5adafc768
style: black format anthropic_messages transformation.py 2026-04-15 18:18:41 -07:00
Ishaan Jaffer
0acd05207b
style: black format health_check.py 2026-04-15 18:18:36 -07:00
Ishaan Jaffer
65061b1e3c
style: black format mcp server.py 2026-04-15 18:18:33 -07:00
Ishaan Jaffer
d8dbb46dcf
style: black format mcp_server_manager.py 2026-04-15 18:18:29 -07:00
Ishaan Jaffer
563e05ebfa
style: black format _types.py 2026-04-15 18:18:24 -07:00
Ishaan Jaffer
c3dbd782f4
style: black format llm_http_handler.py 2026-04-15 18:18:18 -07:00
Ishaan Jaffer
9114b0da96
fix(ci): sync uv.lock with pyproject.toml 2026-04-15 18:16:22 -07:00
ishaan-berri
cb8fc480e6
Merge pull request #25732 from harish876/health-check-oom
Optimize database query to prevent OOM errors during health checks
2026-04-15 18:13:11 -07:00
Joe Reyna
f92490c308
fix: make PodLockManager.release_lock atomic compare-and-delete (re-land #21226) (#24466)
Some checks are pending
Unit Tests: Proxy DB Operations / proxy-db (auth-checks, tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Waiting to run
Unit Tests: Proxy DB Operations / proxy-db (key-generation, tests/proxy_unit_tests/test_key_generate_prisma.py, 30, 0) (push) Waiting to run
Unit Tests: Proxy DB Operations / proxy-db (remaining, tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py, 30, 8) (push) Waiting to run
Unit Tests: Security / security (push) Waiting to run
* fix: make PodLockManager.release_lock atomic compare-and-delete

Re-lands #21226 (reverted in #21469).

release_lock() previously did GET + compare + DEL in separate calls,
leaving a window where another pod could reacquire the lock between
the GET and DEL, causing a stale owner to delete a live lock.

Fix: use a Redis Lua script for atomic compare-and-delete. Script
registration is cached per PodLockManager instance. Falls back to
the old GET+DEL path for cache backends that don't expose
async_register_script.

Original revert was due to e2e tests running in CI without Redis.
Those tests now carry @pytest.mark.skip(reason="Requires Redis connection.")
so this re-land is safe.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add Lua fallback on execution error + test coverage gaps

Address Greptile review feedback on #24466:

1. Wrap Lua script execution in try/except — if Redis clears loaded
   scripts (restart) or scripting is disabled, fall back to GET+DEL
   rather than letting the exception propagate and leave the lock held
   until TTL. Reset cached script handle so the next call re-registers.

2. Add test_release_lock_lua_path_emits_released_event — verifies
   _emit_released_lock_event is called when Lua path returns 1.

3. Add test_release_lock_falls_back_to_get_del_when_lua_execution_fails
   — verifies the fallback path is taken and script handle is reset.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 17:33:21 -07:00
yuneng-jiang
3914226ed7
Merge pull request #25796 from BerriAI/litellm_yj_apr14
[Infra] Merge dev branch
2026-04-15 17:01:23 -07:00
yuneng-jiang
2f72eb6637
Merge pull request #25821 from BerriAI/litellm_/funny-meninsky
[Infra] Remove unused publish_proxy_extras and prisma_schema_sync jobs from CircleCI config
2026-04-15 16:52:01 -07:00