Commit graph

46391 commits

Author SHA1 Message Date
Ishaan Jaff
d37eb2ce18
test: retain azure ocr URL coverage 2026-09-02 20:20:38 -07:00
Ishaan Jaff
978f314221
fix: hide ocr native response payload 2026-09-02 20:20:38 -07:00
Ishaan Jaff
8bb2cd36f9
test: map azure document intelligence ocr parity 2026-09-02 20:15:20 -07:00
Ishaan Jaff
84b13e6fc3
feat: retain ocr response parameters 2026-09-02 20:15:20 -07:00
Ishaan Jaff
fdac3c4732
test: cover azure ocr entra authentication 2026-09-02 20:15:20 -07:00
Ishaan Jaff
10717607b4
fix: accept azure ocr bearer authentication 2026-09-02 20:15:20 -07:00
Ishaan Jaff
cad0971095
feat: pass ocr response parameters to providers 2026-09-02 20:15:20 -07:00
Ishaan Jaff
774e5a7e5e
fix: forward bearer auth when polling azure ocr 2026-09-02 20:15:20 -07:00
Ishaan Jaff
56dfe8926e
fix: initialize vertex ocr native fields 2026-09-02 20:15:19 -07:00
Ishaan Jaff
ba4b644243
fix: initialize ocr response native fields 2026-09-02 20:15:19 -07:00
Ishaan Jaff
8db49ffae9
feat: preserve azure ocr native response fields 2026-09-02 20:15:19 -07:00
Ishaan Jaff
c8b0d0ff1e
feat: support parameterized ocr responses 2026-09-02 20:15:19 -07:00
Ishaan Jaff
60ce274ea7
feat: align azure document intelligence ocr transform 2026-09-02 20:15:19 -07:00
Ishaan Jaff
a04ef4494c
chore: remove ledger.py/validate_ledger.py/core after the strategies move
Old-path halves of the ledger.py -> shared/parity/ledger.py,
validate_ledger.py -> strategies/unit_tests/mapping_validator.py, and
core/ocr -> strategies/unit_tests/ledgers/ocr renames, split into their
own commits above.
2026-09-02 18:13:15 -07:00
Ishaan Jaff
db0de93a78
test: point at the relocated ledger/mapping_validator modules 2026-09-02 18:13:01 -07:00
Ishaan Jaff
42fa20e25f
refactor: point cli.py at the relocated mapping_validator module 2026-09-02 18:12:58 -07:00
Ishaan Jaff
f2b9cd272f
chore: move ocr ledger data under strategies/unit_tests/ledgers
Ledger JSON data now lives next to the code that owns its path
convention (mapping_validator.ledger_path_for) instead of a separate
top-level core/ directory.
2026-09-02 18:12:54 -07:00
Ishaan Jaff
ce83ef7404
refactor: move validate_ledger into strategies/unit_tests/mapping_validator
Relocates the ledger audit/report logic under strategies/unit_tests to
match the harness's strategy-scoped layout. Now composes the schema
from shared.parity.ledger and the enumerators from python_runner.py/
rust_runner.py instead of owning that logic inline.
2026-09-02 18:12:50 -07:00
Ishaan Jaff
ede610816c
refactor: split rust test enumeration into its own module
rust_runner.py owns the #[test]/#[tokio::test] regex scan, mirroring
python_runner.py's split out of the old validate_ledger.py.
2026-09-02 18:12:46 -07:00
Ishaan Jaff
420a4811ab
refactor: split python test enumeration into its own module
python_runner.py owns walking a Python test file's AST for test_*
functions and classes, separated out ahead of the strategies/unit_tests
mapping_validator restructure.
2026-09-02 18:12:43 -07:00
Ishaan Jaff
34e9c906fd
refactor: extract shared parity ledger schema out of ledger.py
Split the SDK-function path convention (ledger_path_for/LEDGER_ROOT) out
of the ledger schema module. shared/parity/ledger.py now only holds the
reusable dataclasses and JSON loader; load_ledger() takes an explicit
path instead of defaulting to OCR.
2026-09-02 18:12:39 -07:00
Ishaan Jaff
3fdc1607ee
test: cover --validate-ledger and per-function ledger reports 2026-09-02 17:55:37 -07:00
Ishaan Jaff
34280bfa25
feat: add --validate-ledger CLI flag
Prints a per-function ledger gap/drift report and skips the dashboard; narrows with the existing --function flag.
2026-09-02 17:55:35 -07:00
Ishaan Jaff
05d0af6653
feat: report ledger gaps per SDK function instead of raising
Replaces the unused exception-based run_audit/LedgerDriftError with a FunctionReport value so a missing ledger is modeled as data, not an error.
2026-09-02 17:55:32 -07:00
Ishaan Jaff
09585ae0de
feat: support per-function ledger paths
Enables looking up a ledger by SDK function instead of a single hardcoded OCR path.
2026-09-02 17:55:29 -07:00
Ishaan Jaff
79586d10cc
fix: point LEDGER_PATH at the new core/ocr location 2026-09-02 17:44:44 -07:00
Ishaan Jaff
45a6a3d659
chore: move OCR test-parity ledger to core/ocr
validate_sub_methods/ mixes strategy-catalog metadata with the ledger. Ledger data belongs under a per-function core/<function>/ path instead.
2026-09-02 17:44:42 -07:00
Ishaan Jaff
f88d994845
test: simplify ledger test to one drift-guard assertion
Replace the ledger-internals unit tests with a single test that runs the real audit against the live repo and asserts every OCR test is accounted for (mapped, unmapped-with-reason, or rust_only), printing the exact diff on failure.
2026-09-02 17:00:31 -07:00
Ishaan Jaff
6c88e5d7c9
test: add regression coverage for the OCR ledger and audit script
Covers schema validation, AST/regex test enumeration, drift detection on both the Python and Rust sides, LedgerDriftError content, and a live-repo clean-audit guard against future drift.
2026-09-02 16:55:14 -07:00
Ishaan Jaff
a009ba4bd1
fix: correct drift in OCR test-parity ledger
Two entries referenced a typo'd Python test name, four duplicated entries already tracked under TestProxySecurityGuard, five real Python tests in test_rust_bridge.py were untracked, and three real Rust custom_logger tests were missing from rust_only_tests. Found by running validate_ledger.py's audit against the live repo.
2026-09-02 16:55:10 -07:00
Ishaan Jaff
305c61d8ca
feat: add drift audit for OCR test parity ledger (WIP, untested) 2026-09-02 16:36:32 -07:00
Ishaan Jaff
f7c0fad2e8
feat: add ledger loader for OCR test parity data 2026-09-02 16:36:29 -07:00
Ishaan Jaff
9a2d3cd70b
test: add OCR python-to-rust test parity ledger 2026-09-02 16:36:27 -07:00
Mateo Wang
3c6b0705b2
Merge pull request #39420 from BerriAI/litellm_bedrock_kb_fake_router_kwarg
test(bedrock): accept the router kwarg in the knowledge base search fake
2026-09-02 16:13:47 -07:00
Yassin Kortam
bc2370f3fd
test(proxy): verify NO_DOCS/NO_REDOC/NO_OPENAPI restrict every doc surface (#39378)
* test(proxy): verify NO_DOCS/NO_REDOC/NO_OPENAPI gate every doc surface

Confirms /docs, /redoc and /openapi.json are reachable by default and
each 404 with no schema in the body when NO_DOCS/NO_REDOC/NO_OPENAPI are
set, and that disabling them does not affect other routes.

* test(proxy): pin the production docs_url construction to the real helpers

Addresses Greptile 4/5 feedback: the disabled-path tests built a fresh
FastAPI() app, which could miss drift in the actual
FastAPI(docs_url=..., ...) call in proxy_server.py. This pins that
exact call site against _get_docs_url/_get_redoc_url/_get_openapi_url.
2026-09-02 16:06:04 -07:00
mateo-berri
8e26d13fa0 test(bedrock): type the router parameter on the knowledge base search fake 2026-09-02 16:03:39 -07:00
ishaan-berri
4c51ca72d6
test: add interactive Rust Python parity harness (#39419)
* test: add interactive Rust Python parity harness

* test: simplify Rust Python parity harness structure

* test: show parity confidence by SDK section

---------

Co-authored-by: yuneng-jiang <yuneng@berri.ai>
2026-09-02 15:51:08 -07:00
mateo-berri
b6b5b31ce4 test(bedrock): accept the router kwarg in the knowledge base search fake 2026-09-02 15:25:05 -07:00
Yassin Kortam
6c5fb0ef6f
fix(proxy): build coordination Redis from REDIS_* env vars unconditionally (#39410)
Coordination Redis (spend counters, budget-window enforcement, and the
reset_spend cache-eviction broadcast) previously only attached when a
deployment set general_settings.coordination_redis or
litellm_settings.cache. Bare REDIS_HOST/REDIS_PORT env vars alone did
nothing, so a multi-replica proxy with no cache block got no cross-pod
coordination at all: a key reset on one pod never cleared another
pod's stale budget enforcement.

The inferred Redis is pinged before being adopted, and a malformed
REDIS_CLUSTER_NODES/REDIS_SENTINEL_NODES value is tolerated too: env
vars can be set for an unrelated reason with nothing reachable there,
and guessing wrong must not turn a previously harmless in-memory-only
proxy into one that fails to boot or raises on its next cache write.
2026-09-02 15:21:15 -07:00
yujonglee
0c0b432cf1
refactor(rust): move audio transcription into core (#39126) 2026-09-02 15:20:54 -07:00
Mateo Wang
2d3e4d6eff
Merge pull request #39417 from BerriAI/litellm_muse_spark_1_3
feat(model_prices): add meta/muse-spark-1.3 and its contributor tier
2026-09-02 15:18:05 -07:00
yucheng-berri
b4f5b6aa94
fix(logging): redact credential query params from the uvicorn access log (#39293)
* fix(logging): redact credential query params from the uvicorn access log

Raw virtual keys reached container stdout two ways:

- `GET /key/info?key=sk-...`, `/global/spend/report?api_key=sk-...`,
  `/key/spend/report`, `/spend/logs`, `/user/daily/activity` and the Gemini
  passthrough routes all put the credential in the request target, and
  `uvicorn.access` had no redaction filter (only `uvicorn.error` did).
- the key budget error interpolates `LiteLLM_VerificationToken.key_name`,
  a column with no enforced shape, into a message that is both logged and
  returned to the caller.

`SecretRedactionFilter` cannot be reused on an access logger: it collapses the
record into `record.msg` and clears `record.args`, and uvicorn's AccessFormatter
unpacks those args at emit time, so every access line would raise TypeError.
`AccessLogRedactionFilter` scrubs the positional args in place instead.

An access line is the one input to the secret regex an unauthenticated caller
controls end to end, so two bounds go with it. The request target is cut back to
a whole query parameter under 512 characters before it is scanned, since a half
parameter is too short to match its own pattern and would be logged raw, and the
dropped tail is not logged at all. The connection-string pattern is bounded too,
because its user half could previously re-scan the rest of the string from every
`://`: a 16 KB URL of `a://` pairs took 314s and now takes 0.12s, with the caps
set high enough that an RDS IAM auth token used as a DSN password still redacts.

Credential query params are terminated by `&` like the existing `key=` and
`sig=` patterns, so redacting one param no longer swallows the rest of the
request line, and a second credential in the same query string is now redacted
on its own instead of surviving once the first one stops the span. `key_name` is
echoed into the budget error only when it still has the masked `sk-...abcd`
shape `abbreviate_api_key` writes, so a value put there by a direct DB write or
a migration falls back to the key alias.

Also point the `/key/info` and spend-report examples at the sha256 hash both
endpoints already accept, so callers stop putting raw keys in URLs that
third-party access logs record.

Resolves LIT-5909

* test(logging): assert on emitted access lines instead of filter registration

The two registration tests checked that an AccessLogRedactionFilter instance
sits in uvicorn.access.filters, which is the shape of the code rather than its
behavior. Handing the logger a real access record and reading what a handler
wrote covers the same wiring and still fails when the registration is removed.

* fix(logging): redact percent-encoded credentials from access logs

?k%65y=sk%2D... is a working credential once the request parser decodes it,
but the redaction patterns match literal text and never see it. Decode the
request target as a detector and drop the query when decoding reveals a
secret. The decoded text is never logged back, so a %0A cannot forge a
following log line

Also accept any four non-space characters in the masked key_name check, since
abbreviate_api_key copies the last four characters of a custom key verbatim
and those can be punctuation or non-ASCII

* fix(auth): keep control codes out of the masked key label

/key/generate accepts a custom key ending in an escape sequence, and
abbreviate_api_key copies those four characters into key_name verbatim, so
the over-budget message carried them to a terminal and a log viewer. Bar
whitespace and C0/C1 control codes from the four, and keep everything else
2026-09-02 15:10:36 -07:00
devin-ai-integration[bot]
a76cb6feaf
feat(mcp): semantic tool search for the native MCP Gateway (#39404)
The mcp_tool_search virtual tool only did substring token matching, so a native MCP client asking for "FX" could not find a tool described as "foreign exchange rates" even though the same catalog is ranked by embeddings on /responses and /chat/completions.

Adds litellm_settings.mcp_tool_search (embedding_model, top_k, similarity_threshold, core_tools). With an embedding model the caller's authorized catalog from _list_mcp_tools is ranked by cosine similarity of name plus description; configured core tools the caller can reach come first and do not consume top_k. Without an embedding model the keyword fallback keeps the old behavior. Settings are hot-reloadable from the DB, exposed on /get and /update mcp_tool_search_settings, and editable from the Admin UI under MCP Servers > Tool Search. The embedding index is shared with agent_search via a new SemanticTextIndex.

Resolves LIT-6751

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 15:09:44 -07:00
devin-ai-integration[bot]
a701effbad
refactor(utils): remove the dead get_api_key provider-key resolver (#39260)
get_api_key had no callers. main.py imported it without using it, and
because main.py declares no __all__, the star import in __init__.py
published it as litellm.get_api_key. It duplicated key resolution that
get_llm_provider_logic already performs, which is how a misspelled env
var survived in it unnoticed until #35985. Drop the definition, the
unused import, the test that pinned the ai21 branch, and ratchet the
lint budgets down by the violations it carried.

Resolves LIT-5245

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 15:06:36 -07:00
devin-ai-integration[bot]
748c2026d7
fix(proxy): word database 503s by whether the fault is transient (#39256)
Permanent Prisma/query-engine faults keep the 503 status and no_db_connection type but stop claiming the database is temporarily unreachable. A permanent fault anywhere in the exception chain outranks the transport error that surfaced it. MCP bridge and DCR flows gain a faulted resolution state with matching wording. Resolves LIT-5208

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 15:05:55 -07:00
devin-ai-integration[bot]
346813b374
fix(proxy/db): keep prisma predicates from raising TypeError under a mocked prisma module (#39253)
Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 15:05:37 -07:00
mateo
6fa02887c4 feat(model_prices): add meta/muse-spark-1.3 and its contributor tier
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-02 22:05:17 +00:00
Mateo Wang
eac2c54141
Merge pull request #39241 from BerriAI/litellm_fix_gateway_injection_scope
fix(spend): keep every-deployment scope on gateway cache-injection marks
2026-09-02 15:02:47 -07:00
mateo-berri
856cce636a Merge branch 'litellm_internal_staging' of https://github.com/BerriAI/litellm into litellm_fix_gateway_injection_scope
# Conflicts:
#	tests/e2e/test_junit_properties.py
2026-09-02 14:54:30 -07:00
Mateo Wang
86ca146ea2
Merge pull request #39271 from BerriAI/litellm_fix_presidio_sibling_callback_leak
fix(guardrails): track and tear down presidio sibling callbacks on delete and update
2026-09-02 14:39:47 -07:00