Commit Graph

38454 Commits

Author SHA1 Message Date
yuneng-jiang
eca6feb6a6
Merge branch 'litellm_yj_may1' into codex/integration-host-credential-guard 2026-05-01 14:42:23 -07:00
Yuneng Jiang
d8f556e18c
[Fix] Auth: Restore Request-Context Model Resolution In Skip-Budget Helper
Merge of #26845 kept the PR's _should_skip_budget_checks helper but lost staging's upgrade to _get_model_from_request_context, so zero-cost models resolved from request headers/query params no longer skipped budget checks. Route the helper through _get_model_from_request_context so this path matches the other 8 model-resolution sites in the file.
2026-05-01 14:39:24 -07:00
yuneng-jiang
b25732f38b
Merge pull request #26845 from stuxf/codex/budget-race-enforcement
chore(proxy): tighten budget spend admission
2026-05-01 14:32:29 -07:00
yuneng-jiang
c2cea58567
Merge branch 'litellm_yj_may1' into codex/budget-race-enforcement 2026-05-01 14:32:18 -07:00
yuneng-jiang
df17ffc386
Merge pull request #26930 from stuxf/codex/vector-store-tenant-guard
chore(vector stores): tighten managed store access
2026-05-01 14:25:51 -07:00
yuneng-jiang
058d717b61
Merge pull request #27010 from BerriAI/yj/fix-lazy-openapi-snapshot-merge
[Fix] Tests: Move Misplaced Import in Lazy OpenAPI Snapshot Test
2026-05-01 14:25:23 -07:00
Yuneng Jiang
4825d94a9d
[Fix] Tests: Move Misplaced Import in Lazy OpenAPI Snapshot Test
The GitHub merge conflict resolver concatenated both test sets but left
`from litellm.proxy._lazy_openapi_snapshot import _normalize_operation_ids`
stranded between functions instead of at the top of the file.
2026-05-01 14:24:53 -07:00
yuneng-jiang
38fae659b5
Merge branch 'litellm_yj_may1' into codex/vector-store-tenant-guard 2026-05-01 14:24:48 -07:00
yuneng-jiang
2fca7ad3ef
Merge pull request #26963 from stuxf/codex/file-endpoint-model-auth
chore(proxy): align resource model auth checks
2026-05-01 14:22:27 -07:00
yuneng-jiang
9e501edece
Merge branch 'litellm_yj_may1' into codex/file-endpoint-model-auth 2026-05-01 14:22:18 -07:00
yuneng-jiang
42122b83f5
Merge pull request #26969 from stuxf/codex/tool-permission-guardrail-fix
chore(guardrails): tighten tool permission checks
2026-05-01 14:17:55 -07:00
yuneng-jiang
f34a2752f6
Merge pull request #26996 from stuxf/chore/ssrf-polling-and-nested-config
chore(security): close two unaddressed SSRF cases
2026-05-01 14:16:39 -07:00
yuneng-jiang
b1fcdb671b
Merge pull request #26643 from BerriAI/litellm_fix-config-update-targeted-upserts
[Fix] /config/update: targeted per-section writes, drop store_model_in_db gate
2026-05-01 12:50:25 -07:00
ryan-crabbe-berri
34b340218e
Merge pull request #26998 from BerriAI/litellm_stream_timeout_midstream_fallback
Fix: trigger fallbacks on mid-stream httpx.TimeoutException
2026-05-01 12:24:04 -07:00
ishaan-berri
231c430200
fix: scope CLI stored token to base_url to prevent cross-domain credential leakage (#26945)
* fix: add expected_base_url origin check to get_litellm_gateway_api_key

* fix: scope get_stored_api_key and save base_url on login

* fix: pass base_url to get_stored_api_key in CLI entrypoint

* fix: scope ProxyClient stored key to base_url

* test: add expected_base_url coverage for get_stored_api_key

* fix: initialize self.http with resolved api_key not raw param

* fix: black formatting in client.py and test_auth_commands.py
2026-05-01 12:11:32 -07:00
ishaan-berri
c06cc560e0
fix(ui): add Your Usage view for admin users on usage page (#26746)
* feat(ui): add "Your Usage" view for admin users on usage page

Admins were forced to use the global usage view with no way to scope it
to their own activity without manually searching for themselves in the
user filter dropdown.

Adds a new "Your Usage" option (admin-only) to the usage view selector.
When selected, it locks the data to the admin's own user_id and hides
the "Filter by user" dropdown.

* feat(ui): wire my-usage view to admin's own user_id in UsagePageView

When usageView is "my-usage", effectiveUserId resolves to the logged-in
admin's own userID. The "Filter by user" dropdown is hidden in this
view (only shown for "global").

* add: screenshots for usage page Your Usage admin fix

* remove: QA screenshots from .github/screenshots
2026-05-01 12:10:47 -07:00
Krrish Dholakia
b14e1d7d6a
refactor: scope /health response to caller's models and tidy display fields (#26935)
* refactor: scope /health response to caller's models and tidy display fields

Two small consistency changes to the /health response:

1. health_endpoint() now narrows _llm_model_list to deployments whose
   model_name is in user_api_key_dict.models, matching how other model
   listing endpoints already scope their output. The same narrowing applies
   to the cached health_check_results dict when background_health_checks is
   enabled, via a new _filter_health_check_results_by_model_ids helper.

2. ILLEGAL_DISPLAY_PARAMS in health_check.py picks up api_base and
   api_version, which are provider routing fields and not part of the
   health response shape.

Tests in tests/test_litellm/proxy/health_endpoints/test_health_endpoints.py
pin both behaviors so future changes do not widen the response shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* address greptile review feedback (greploop iteration 1)

- tests: extend background-cache test with model_id on cached entries plus
  positive assertions that model-a's deployment is the one returned, so
  the test is no longer satisfied by an empty result.
- _health_endpoints.py: add a verbose_proxy_logger.debug line when a scoped
  key has accessible model_names but the matching deployments have no
  model_info.id, so the empty cache-result case is observable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* make background-cache test's non-vacuity explicit

Restructure test_health_endpoint_filters_background_cache_by_user_access
so the assertions positively pin the post-scoping result (one entry,
model_id == "id-a", api_base == https://example-a.test) and add fixture
sanity checks that confirm the source cache had two entries and every
cached entry carries a model_id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* gate api_base in /health response on proxy-admin role

Replace the blanket strip of api_base / api_version with a role-aware
post-processor:

- api_base is now left in the cleaned per-deployment dict that
  _clean_endpoint_data produces (api_version stays in the denylist).
- health_endpoint() removes api_base from each endpoint entry before
  returning when the caller's user_role is not PROXY_ADMIN /
  PROXY_ADMIN_VIEW_ONLY. The strip uses a copy so the shared
  health_check_results cache still carries api_base for subsequent
  admin reads.

Net effect: a proxy admin can still see which Vertex region or Azure
resource is healthy in the /health output, while non-admin keys (and
read-only keys) only see model / model_id / status fields.

Tests:
- test_health_endpoint_admin_sees_api_base_non_admin_does_not pins both
  branches and verifies the cache is not mutated.
- test_clean_endpoint_data_strips_credentials_but_keeps_api_base
  replaces the previous mask/drop tests now that the cleaning helper
  no longer touches api_base.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* address review feedback: api_version symmetry, missing-id warnings, deprecation header

Three blockers raised in review:

1. api_version asymmetry — api_base was role-gated for proxy admins, but
   api_version was unconditionally stripped via ILLEGAL_DISPLAY_PARAMS.
   Move api_version out of the credential denylist and into a new
   ADMIN_ONLY_HEALTH_DISPLAY_PARAMS tuple alongside api_base, so admins
   keep both routing fields and non-admins lose both. Useful for telling
   apart Vertex regions or Azure api-versions from the /health response.

2. Silent empty results when scoped key's deployments lack model_info.id —
   raise the existing log from .debug to .warning, and add a structured
   "warnings" field to the response so the caller can distinguish "no
   deployments configured" from "deployments excluded due to missing
   model_info.id".

3. Migration signal for the api_base / api_version removal — when a
   non-admin caller hits /health, set a "Litellm-Health-Field-Notice"
   response header so existing dashboards or scripts that parsed those
   fields can detect the change programmatically rather than silently
   seeing absent keys.

Tests adjusted: existing background-cache test injects a Response stub,
admin-vs-non-admin test now asserts both api_base and api_version are
gated and asserts the notice header. New test covers the warnings field
when a scoped key's deployments are missing model_info.id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* defensive copies + clarifying comments in /health filter

- _filter_health_check_results_by_model_ids now shallow-copies each
  retained endpoint dict before returning. The shared module-level
  health_check_results cache should never be mutated by downstream
  transforms, even though _strip_admin_only_fields_from_health_result
  already builds new dicts today.
- Document the live (model_name) vs cache (model_id) scoping asymmetry
  so future readers do not have to derive it from the warnings field.
- Document why _PROXY_ADMIN_ROLES includes PROXY_ADMIN_VIEW_ONLY (read-
  only operators need routing fields to diagnose health).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: yuneng-jiang <yuneng@berri.ai>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:01:27 -07:00
yuneng-jiang
02582466c4
Merge pull request #24340 from BerriAI/litellm_staging_03_21_2026
Litellm staging 03 21 2026
2026-05-01 11:57:44 -07:00
user
90fd791e0d
fix(security): close P1 recursion-DoS + P2 hostname leak in SSRF fixes
Greptile follow-ups on the prior commit:

- (P1) ``is_request_body_safe`` recursed into ``litellm_embedding_config``
  with no depth bound, so a request body 1000 levels deep could exhaust
  Python's call stack and surface a 500 ``RecursionError``. Refactored
  the check to be iterative (single-level descent into a fixed list of
  nested-config keys) and extracted the per-dict banned-param scan into
  a helper that's shared between the root and the nested call sites.
  Also fixes the ``recursive_detector`` CI job that was triggered by
  the recursive-by-name pattern.

- (P2) ``assert_same_origin`` error messages identified the mismatching
  component but echoed the ``expected`` host and the candidate
  hostname back to the caller. In the SSRF threat model the caller is
  the attacker, so reflecting that information was a secondary leak of
  operator infrastructure. Messages now identify only *which*
  component mismatched (scheme / host / port) without naming names.

- (P2) ``_NESTED_CONFIG_KEYS`` was defined after the function that used
  it. Hoisted the constant (and the new ``_BANNED_REQUEST_BODY_PARAMS``
  tuple) above the function for readability.

Adds a 1000-level-deep nested config test that asserts no
``RecursionError`` and a hostname-leak test that asserts no operator
host appears in the rejection message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 18:52:55 +00:00
Ryan Crabbe
35133e3550
Fix: trigger fallbacks on mid-stream httpx.TimeoutException
The async CustomStreamWrapper.__anext__ caught httpx.TimeoutException
and re-raised it raw, bypassing _handle_stream_fallback_error. The
Router's FallbackStreamWrapper only reacts to MidStreamFallbackError,
so stream_timeout firing mid-stream never triggered fallbacks the way
connection-phase timeout does.

Route timeouts through _handle_stream_fallback_error like every other
exception so they wrap into MidStreamFallbackError and the Router can
switch to a fallback model.
2026-05-01 11:46:17 -07:00
ishaan-berri
fdd9f3d129
fix: block path traversal SSRF in BitBucket, Arize Phoenix, and AssemblyAI clients (#26943)
* fix: sanitize BitBucket file path to block path traversal SSRF

* fix: sanitize Arize Phoenix prompt_version_id to block SSRF

* fix: sanitize AssemblyAI transcript_id to block SSRF

* test: add path traversal SSRF security tests for BitBucket client

* test: add SSRF security tests for Arize Phoenix client

* style: black format arize_phoenix_client.py

* style: black format assembly_passthrough_logging_handler.py

* test: add SSRF security tests for AssemblyAI transcript_id validation

* fix: move AssemblyAI transcript_id validation before try/except so ValueError propagates
2026-05-01 11:45:12 -07:00
user
0d4875dec9
chore(security): close two unaddressed SSRF cases
Two SSRF findings were OPEN with no in-flight fix; both are closed
now using narrow defenses that key off existing trust boundaries.

VERIA-6 (Milvus ``litellm_embedding_config``):
``is_request_body_safe`` already blocks ``api_base`` / ``api_key`` /
``langfuse_host`` / ``s3_endpoint_url`` / etc. at the *root* of the
request body, gated by an admin opt-in (``allow_client_side_credentials``
or per-deployment ``configurable_clientside_auth_params``). The bug is
that the Milvus vector-store transformer unpacks
``litellm_embedding_config`` into ``litellm.embedding(**embedding_config)``,
so a caller can smuggle the same banned params in via nesting and bypass
the check. Fix: ``is_request_body_safe`` now recurses into a known list
of nested-config dicts (``litellm_embedding_config`` for now) and applies
the same banned-param check with the same admin opt-in. Admin-side
vector-store config flows through ``litellm_params`` rather than the
request body, so it's unaffected.

VERIA-51 (polling URLs returned by upstream APIs):
Azure DALL-E 2, Azure Document Intelligence, and Black Forest Labs
all blindly fetched a polling URL returned by the upstream and
attached the operator's API key to the request. A compromised upstream
or a future API contract change could redirect credentials anywhere.
New ``url_utils.assert_same_origin(candidate, expected)`` helper checks
scheme, host (case-insensitive), and port (with default-port
normalization). Applied at all five polling sites: Azure DALL-E
sync+async, Azure DI sync+async, BFL image generation sync+async, BFL
image edit sync+async. Cross-origin polling URLs now raise rather than
forward credentials. The Azure DALL-E ``Expected 'status' in response``
exception no longer reflects the raw response body — that path turned
Blind SSRF into Full-Read SSRF for the limited window before the
origin check fully closed it.

Tests: 7 ``assert_same_origin`` unit tests, 6 ``is_request_body_safe``
nested-config tests, 5 polling-site rejection tests + 1 same-origin
sanity check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 18:43:47 +00:00
ishaan-berri
32704ff7b2
fix(projects): project dropdown empty for internal_user (3 bugs) (#26664)
* fix(projects): fire useProjects hook for all authenticated users, not just admins

* fix(routes): add /project/list and /project/info to internal_user_routes allowlist

* fix(projects): use members_with_roles + LiteLLM_UserTable.teams for membership checks

* feat(ui): add "Your Usage" view for admin users on usage page

Admins were forced to use the global usage view with no way to scope it
to their own activity without manually searching for themselves in the
user filter dropdown.

Adds a new "Your Usage" option (admin-only) to the usage view selector.
When selected, it locks the data to the admin's own user_id and hides
the "Filter by user" dropdown.

* feat(ui): wire my-usage view to admin's own user_id in UsagePageView

When usageView is "my-usage", effectiveUserId resolves to the logged-in
admin's own userID. The "Filter by user" dropdown is hidden in this
view (only shown for "global").

* add: screenshots for usage page Your Usage admin fix

* fix(ui): gate useProjects on admin roles to fix failing unit test

* feat(proxy): add /project/list and /project/info to internal user routes

* fix(enterprise): use members_with_roles and litellm_usertable.teams for project access checks

* remove .github screenshots and workflow file from PR
2026-05-01 11:42:22 -07:00
user
2ed4b5968d Merge remote-tracking branch 'origin/litellm_internal_staging' into HEAD
# Conflicts:
#	litellm/proxy/auth/auth_checks.py
2026-05-01 11:37:43 -07:00
harish-berri
c8fb77f119
Merge pull request #25980 from BerriAI/litellm_metrics_auth
Fix /metrics hang when require_auth_for_metrics_endpoint is true and auth succeeds
2026-05-01 11:01:39 -07:00
Yuneng Jiang
650821b538
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix-config-update-targeted-upserts
# Conflicts:
#	tests/test_litellm/proxy/test_proxy_server.py
2026-05-01 10:38:34 -07:00
Sameer Kankute
8300657af9
fix(mcp): preserve oauth2 m2m auth for tools routes (#26871)
* Fix tool/list M2M creds issue

* Fix tool call creds issue

* Fix greptile review

* Fix lint

* Fix lint

* Fix lint

* Fix lint
2026-05-01 10:26:10 -07:00
Mateo Wang
a155ea1e8a
Merge pull request #26076 from BerriAI/litellm_vertex_model_garden_xai_openapi
feat(vertex_ai): Model Garden OpenAPI for publisher model ids
2026-05-01 10:15:58 -07:00
harish-berri
32ab390e7e
Merge pull request #26202 from BerriAI/litellm_token_verification_query_opt
Litellm token verification query optimization
2026-05-01 10:10:07 -07:00
Mateo Wang
026ee8839c
Merge pull request #25270 from BerriAI/litellm_oss_staging_04_06_2026 2026-05-01 08:04:25 -07:00
Mateo Wang
6552e3c5c0
Merge pull request #26402 from BerriAI/litellm_azure-container-file-routing-fix 2026-05-01 07:50:37 -07:00
Mateo Wang
dddbfd54a1
Merge pull request #26950 from BerriAI/litellm_batch_model_id_mapping 2026-05-01 07:47:47 -07:00
Sameer Kankute
a94ae62706
Merge pull request #26984 from BerriAI/litellm_internal_staging
merge main
2026-05-01 19:03:59 +05:30
Sameer Kankute
e656b2a47b
correct model map 2026-05-01 18:07:33 +05:30
Sameer Kankute
71e2b6fcad
Fix reviews 2026-05-01 18:05:08 +05:30
Sameer Kankute
19813527fa
feat(vertex_ai): Model Garden OpenAPI for publisher model ids
- Route publisher/model ids (e.g. xai/grok) to .../endpoints/openapi; keep model in JSON body
- Add model_prices keys for vertex_ai/openai/xai/grok-*
- Document xAI Grok on vertex_partner (aligned with GPT-OSS)
- Add tests for create_vertex_url and body-model heuristic

Made-with: Cursor
2026-05-01 18:05:08 +05:30
Sameer Kankute
475220ecc6
Fix greptile review 2026-05-01 17:46:37 +05:30
Sameer Kankute
e0398cade7
fix(caching): defer streaming cache-hit callbacks for all stream=True
Success handlers already run when CustomStreamWrapper or
CachedResponsesAPIStreamingIterator finishes replay. Logging at
cache-hit time for acompletion/completion streaming duplicated spend
and callbacks. Align tests with deferred behavior.

Made-with: Cursor
2026-05-01 17:03:32 +05:30
Sameer Kankute
15288f3ae7
test: include response key in response.completed chunk for ID hook test
_base_process_chunk only encodes response IDs when parsed_chunk contains
a top-level "response" key. Align test_process_chunk_completed_response_
updates_id_and_usage_cost with that contract and test_base_responses_api_streaming_iterator.

Made-with: Cursor
2026-05-01 15:41:17 +05:30
Sameer Kankute
900ef454c8
test: fix Bedrock PDF tool-result bytes assertion in factory test
The test supplies a minimal PDF base64 payload but expected the wrong
constant (base64 for "test"). Assert against the same pdf_b64 value
and drop the unused import.

Made-with: Cursor
2026-05-01 15:35:30 +05:30
user
8538193bd3 chore(proxy): stabilize lazy openapi snapshot 2026-05-01 01:10:44 -07:00
user
5e7c9e68e6 chore(guardrails): satisfy tool permission typing 2026-05-01 01:00:19 -07:00
user
150a34f2b0 chore(guardrails): tighten tool permission checks 2026-05-01 00:55:04 -07:00
user
83ed317c50 track reservation entry before counter write 2026-05-01 00:09:51 -07:00
yuneng-jiang
eab0075353
Merge pull request #26805 from BerriAI/litellm_auth_bypass_tag_based_routing
add test(tag-routing): prevent header regex bypass for strict plain t…
2026-05-01 00:08:57 -07:00
user
403bbc3b88 degrade budget reservation cache failures 2026-04-30 23:53:36 -07:00
Sameer Kankute
94162916a8
Fix lint and ruff 2026-05-01 12:14:53 +05:30
Sameer Kankute
d2346b5259
Fix prompt factory 2026-05-01 12:09:19 +05:30
Baqiao
ec38f2b17b
feat(xai): add parallel_tool_calls to supported params (#25106) 2026-05-01 12:06:56 +05:30
shubham-arora-clear
f49c91ea92
fix(bedrock): handle document content blocks in Converse API message conversion (#24644)
* fix(bedrock): handle document content blocks in Converse API message conversion

Document content blocks (used for PDF support) were silently dropped
during message conversion for Bedrock's Converse API. The content block
processing loop only handled text, image_url, and file types — document
blocks were skipped without warning, causing the model to respond as if
no document was provided.

Adds document block handling in three locations:
- Sync user message processing (_bedrock_converse_messages_pt)
- Async user message processing (_bedrock_converse_messages_pt_async)
- Tool result conversion (_convert_to_bedrock_tool_call_result)

Fixes #24641

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use _validate_format for proper MIME type to Bedrock format mapping

Address Greptile review: naive media_type.split("/")[1] produced invalid
Bedrock format names for complex MIME types (e.g. OOXML → docx, text/plain
→ txt, text/markdown → md). Now reuses BedrockImageProcessor._validate_format
which handles all MIME types correctly via mimetypes + fallback.

Also fixes test assertions to expect correct Bedrock format values and adds
text/plain and text/markdown test cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: reject non-base64 document sources with a clear error

URL-type document sources (e.g. {"type": "url", "url": "..."}) would
crash with an opaque KeyError on missing 'media_type'. Guard at the top
of _process_document_message and raise a clear ValueError since Bedrock
Converse only supports base64-encoded document sources.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-01 12:06:53 +05:30