mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* feat(python-compat): port urllib.parse urlsplit, urlparse and urlunparse
* fix(vertex_ai): shape Claude Messages requests like Python (auth header, betas, output_format, URL)
* test(vertex_ai): stub the Google token in Messages route tests
* fix(vertex_ai): attribute the anthropic-version refusal to the provider and model
* test(vertex_ai): parity cases for Claude Messages request shaping
* docs(vertex_ai): record the Messages shaping rules
* feat(vertex_ai): classify GCP credential failures by the stage that failed
* fix(vertex_ai): raise Python's Google auth exception classes for native credential failures
Map Rust's GCP credential-acquisition stage to the exception Python's
vertex token path raises (RefreshError, TransportError,
DefaultCredentialsError, ValueError) and name Vertex's default host in
transport failures without an api_base. Read only for vertex_ai.
* fix(vertex_ai): name the unreadable credentials file as Python does and add vertex credential parity cases
* test(vertex_ai): build the SDK token rejection without a reqwest client
* fix(vertex_ai): port request labels, regional cost location and beta-gated field stripping to Rust Messages
* test(vertex_ai): satisfy clippy in the labels tests
* test(vertex_ai): parity cases for request labels, regional cost and beta-gated fields
* test(vertex_ai): name the unreserved label fields case for what it checks
* test(vertex_ai): parity case for the regional uplift on a proxy-built logging object
* test(vertex_ai): keep only regional cost cases that reproduce the proxy logging gap
* feat(vertex_ai): add a Vertex Messages-only GCP login matching Python's load_auth
* fix(vertex_ai): log Vertex Messages in before building its URL, like Python's load_auth
* test(vertex_ai): route Vertex Messages by the model's supported regions
* test(vertex_ai): mark Google login failures for the Python route
* test(vertex_ai): parity cases for the Vertex Messages login
* fix(vertex_ai): send Vertex metadata and Resource Manager lookups through the shared HTTP pool
* fix(vertex_ai): refresh Vertex Messages authorized users at Google's token endpoint like google-auth
* fix(vertex_ai): map Vertex Messages login failures through one marker
Rust now names the exception class, text and any credentials file for every
Vertex Messages login failure, and the host raises it. The stage marker,
its classifier and the vertex_failures module are gone. A credentials file
failure goes through Python's own raise_vertex_credentials_failure, so its
log names the path and the reason. A host without google-auth fails the
login with Python's ImportError.
A vertex_location with one trailing newline is accepted, as Python's
regex accepts it. The URL it builds is refused the way httpx refuses it,
so the call never leaves the process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* feat(vertex_ai): log Vertex Messages in with external account authorized user ADC
google-cloud-auth has no builder for these workforce identity credentials,
so this ports google-auth's: the file loads only when it holds a valid token
or the fields to refresh one, and the refresh token is exchanged at the
file's token_url with basic client auth. A refused refresh raises the
OAuthError google-auth raises.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* feat(vertex_ai): cache vertex messages tokens per key-file version
Mint service-account tokens natively, keep tokens until google-auth
calls them stale, refresh stale tokens once in the background, refresh
expired ones single-flight, reload once on invalid_grant, and keep the
earlier key file's credentials when a replacement does not load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* test(vertex_ai): cover vertex messages key-file rotation, fallback and reauth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): send vertex messages service-account grants as google-auth does
Sign the assertion over json.dumps of google-auth's header and claims,
put assertion before grant_type in the form, and send accept: */*.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): log vertex messages credential load failures as python does
Log load_auth failures and failed reauthentication retries on the
LiteLLM logger with Python's text, for the Vertex AI Messages login only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): warn when vertex messages drops disabled thinking
Python warns when it omits thinking={'type': 'disabled'} for an
always-on-thinking model. Warn on the Vertex AI route only; the native
Anthropic route stays silent, as it is on main. Parity cases now compare
warnings for the disabled-thinking drop and the missing-project login.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* style(rust_bridge): suppress the cast ban on the cast import itself
* refactor(http): share python requests' proxy and CA bundle rules
Move the azure_ai token transport's reading of HTTPS_PROXY/NO_PROXY and
REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE into litellm-http so the Vertex AI
Messages login can reuse it. Azure behaves as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): mint vertex messages tokens natively as google-auth does
- Send every token request through python requests' proxy and CA
bundle rules, verifying against the host's certifi bundle by default.
- Exchange external accounts (file, url, executable, AWS metadata and
explicit AWS) at STS natively, reading only access_token and
expires_in; a missing token refreshes once more, then raises
main's ValueError.
- Refresh authorized users with google-auth's form post.
- Raise Python's AttributeError/TypeError crashes for non-dict JSON.
- Keep one login cache per model, as Python's per-model config does.
- Warn when a model's supported_regions override the location.
- Word a TLS close before headers as a disconnect, for vertex_ai only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): stop replaying python helpers for vertex messages failures
- Rust writes the unsendable-URL message; the host raises InvalidURL
with it instead of parsing the URL through httpx.
- Rust logs a credentials file failure's path and reason; the host
raises the file-failure ValueError Rust names.
- A connect failure carries the origin Rust sent it to; the host names
that host instead of recomputing the Vertex base.
- The service-account JWT is built from serde structs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): read credential truthiness through python-compat
Replace the vertex messages loader's local truthiness helpers with one
json_truthy in python-compat, called where credential JSON is read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): raise plain typed failures for bad vertex messages credentials
Owner ruling on review #8: stop imitating Python crash classes and
repr texts. Unusable credentials raise ValueError or google-auth's
DefaultCredentialsError/MalformedError/InvalidResource, and unreadable
token replies raise RefreshError, all with plain messages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): build the vertex messages url without the urllib port
Owner ruling on review #10: split a custom api_base into origin, path,
query and fragment with a narrow builder instead of python-compat's
urlsplit/urlparse/urlunparse port, which nothing else used and is
removed with its fixtures. URLs match Python's for every normal base
(checked against a Python-generated table); ;params bases differ, as
approved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): drop the google-auth import check from vertex messages
Owner ruling on review #3: the native login never needs google-auth, so
a Vertex AI Messages call no longer imports it to raise Python's
ImportError when it is missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): refuse a vertex location with a trailing newline at validation
Owner ruling on review #2: stop copying re's $-before-newline quirk. A
location with a trailing newline gets litellm's 'Invalid vertex_location
format' ValueError, where Python fails later with InvalidURL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* refactor(vertex_ai): parse the caller's vertex labels header with serde_json
Owner ruling on review #12: the X-Vertex-AI-Labels JSON is read with
serde_json (preserve_order) instead of python_json::loads, so NaN or
Infinity makes the header invalid and its labels are skipped. The header
sent to Google keeps Python's json.dumps spacing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* feat(messages): serve vertex ai claude messages on rust only
vertex_ai Messages calls whose model Python's partner config serves as
Claude now run on Rust with no flag and no Python fallback. Gemini,
Llama, Mistral, other partner models and Messages passthrough keep their
Python targets. The parity suite drops its preview rule, so the real
catalog decides, and the vertex safeguards contract no longer asserts
Python routing.
* chore(rust): refresh cargo lock after rebase
* refactor(vertex_ai): parse vertex credentials and token replies into typed structs
Credentials files, token endpoint replies, executable answers and the
request label config are deserialized once into typed structs, so the
login code no longer passes serde_json values around or prints them the
way Python's str() would. A credentials field of an unexpected JSON type
is now refused when the file is read.
* refactor(vertex_ai): say rust instead of native for the vertex messages port
* refactor(vertex_ai): move the python compat helpers into python-compat
The or-chain over credential sources, urllib's quote safe set, urlsplit,
the validating base64 decoder, unicodedata categories and the JSON type
name now live in python-compat, and the vertex code calls them where it
reads loose input.
* refactor(vertex_ai): word vertex login failures and logs in litellm's own terms
Login failures keep the exception class Python raises but no longer copy
google-auth's and requests' text. Whether a refused refresh reloads the
credentials now comes from the token endpoint's parsed error field, not
from searching the failure text. The credential and region logs keep
their level with Rust wording.
* docs(vertex_ai): document the vertex messages login files and structs
* refactor(vertex_ai): raise vertex login failures from a fixed allowlist of classes
The host no longer looks a google.auth exception up by whatever name Rust
sends. It raises one of the classes Rust's login can name and leaves any
other name to the usual failure mapping.
* test(vertex_ai): compare rust-worded vertex login failures by class and status
* test(vertex_ai): capture the python vertex messages parity legs as fixtures
The vertex parity groups now compare Rust against the Python leg captured
once through MESSAGES_PARITY_DUMP, with ports and temporary directories
written as placeholders, so the Python request path can go.
* refactor(vertex_ai): drop the python vertex messages request path now served by rust
* docs(vertex_ai): note that a caller authorization header reaches the provider beside the minted token
* docs(vertex_ai): note the kept /v1 doubling for custom vertex api_base
* refactor(vertex_ai): write the vertex labels header with serde_json
* refactor(messages): raise connection failures with litellm's own text naming the host
Drop messages_sent_origin and the host code that rebuilt aiohttp/httpx connection-error text from
Python's SSL config. The Connect error now names the host (never the rest of the URL) it could not
reach; class and status are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): read at most the size limit of a vertex_credentials file
Read one byte past the 4-byte-per-character bound, so /dev/zero or a huge file is refused without
reading it all, and load the source on a blocking thread off the async runtime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* perf(vertex_ai): dedupe request labels in linear time
Track seen keys in a HashSet and stop once the 32 labels Vertex AI keeps are found, keeping
first-occurrence order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): redact secrets in the Debug of credentials types
Derive veil::Redact on the service account, authorized user, external account (and its AWS keys,
client secret, source headers and executable response), external authorized user and token reply
types, and redact SdkJson as a whole, per the rust-redaction skill.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(messages): refuse a URL with a control character only for vertex_ai
anthropic, azure_ai and bedrock send such a URL as reqwest cleans it, as on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* chore(vertex_ai): review nits
Make the unreachable GcpAccessToken arm in resolve_auth an error, fix the google login marker doc,
drop dated ruling references from comments and describe urlsplit in the urllib module doc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): log a credentials file failure from the blocking read
load_vertex_credentials_source runs on a spawn_blocking thread, where the call's logger is not the
default, so the file's path and problem never reached LiteLLM's log. Run it under the caller's
dispatcher and span.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(vertex_ai): replace a labels header Python cannot encode instead of failing
With vertex_request_label_fields set, the proxy replaces every caller X-Vertex-AI-Labels, so Python
never encodes the caller's value and the call succeeds. The host's ASCII check held such a value back
first and failed the call with 'ascii' codec can't encode. For vertex_ai with label fields set, the
check now leaves the labels header to the replacement (dropping a value that is not text). Unset,
the header is still held back and fails as on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* chore(vertex_ai): use main's python-compat type_name after the rebase
main added json::type_name and imports it in thinking.rs, so the branch's copies of the same helper
go.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bne5zQXAS7BUJoh6pGX7NQ
* fix(rust): default vertex shaping in gateway router deployments
* fix(auth-gcp): bound vertex subject-token file reads
Read external-account subject-token files and executable output files through one shared helper that caps the read at MAX_CREDENTIALS_FILE_BYTES + 1 on a blocking thread, so /dev/zero is refused by its size and a FIFO no longer blocks a tokio worker. An over-size file is a RefreshError.
* fix(auth-gcp): sign vertex service-account assertions with ring
Sign the RS256 JWT bearer assertion with ring's RsaKeyPair (RSA_PKCS1_SHA256) instead of jsonwebtoken's rust_crypto backend, which pulls in rsa 0.9 (RUSTSEC-2023-0071). PKCS#8 and PKCS#1 PEM keys are still accepted, and a fixed-key test pins the assertion byte-for-byte to the one jsonwebtoken produced. Drops jsonwebtoken, rand and rsa from auth-gcp.
* fix(auth-gcp): keep IAM access tokens out of malformed-reply errors
* fix(auth-gcp): keep credential executable output out of errors
* test(vertex): store captured Python parity fixtures as compact JSON
* refactor(rust_bridge): share one native messages rule for anthropic, azure_ai and vertex_ai
azure_ai and vertex_ai serve native Messages only for Claude, so the rule now
requires Rust only for the Messages target. A call whose target cannot be
computed no longer refuses a non-Claude azure_ai model that Python serves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(auth-gcp): log Vertex Messages in through google_cloud_auth and the shared loader
Claude on Vertex /v1/messages now builds every credential kind with Google's
Rust SDK through the shared GcpAuth loader instead of a hand-written login.
- identity.rs: additive SdkCredentials builder (service account, authorized
user with a fixed token_uri, external account, impersonated, programmatic,
impersonated-from, metadata), keyed loads, eviction on a non-transient
token failure, and a key-file cache key that follows inode, mtime and size.
The loader traits, GcpAuth::default and NativeProviderLoader are unchanged.
- Service accounts use the SDK's self-signed JWT; a missing private_key_id or
project_id is filled with an empty string; PKCS#1 keys fail as ValueError.
- explicit_aws.rs keeps litellm's own aws_* login as an SDK subject token
provider; AWS metadata, file, URL and executable sources go to the SDK.
- compat_certificate_source.rs and compat_external_account_authorized_user.rs
are small backwards-compat logins for what the SDK lacks.
- SDK failures map to google-auth's exception class per category; a TLS
certificate failure with only REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE set says to
set SSL_CERT_FILE.
- Deleted the hand-written service account, authorized user, external account,
AWS metadata, token cache, requests transport and certifi plumbing, the
per-model cache and the ring dependency.
* test(parity): treat the service account's self-signed JWT as an approved difference
Owner ruling Q1: Rust signs a service account's token itself with Google's
Rust SDK instead of minting one at token_uri. The Vertex fixture comparison
reads a parity service account's JWT bearer as the token Python's parity
token endpoint granted, and the case pinning an unreachable service account
token_uri is removed with its fixture, since that endpoint is never called.
* fix(auth-gcp): keep Google SDK error text out of Vertex login failures
* fix(auth-gcp): restore the vertex credential failure error log
Python's _load_auth_or_earlier_key_file logs "Failed to load vertex
credentials. Check to see if credentials containing partial/invalid
information. Error: ..." on every load_auth failure, and the proxy's
health check looks for that text. The log went away with logins.rs.
VertexMessagesAuth::login now logs it when the credentials do not load,
when the first token of freshly loaded credentials fails, and when the
project does not resolve. Only the login failure's own message follows
"Error:", and the two failures that still quoted Google SDK build errors
now use the fixed unloadable-credentials message.
* fix(auth-gcp): resolve oidc/ web identity tokens for Vertex explicit AWS keys
Claude on Vertex /v1/messages built the explicit AWS login from an
external_account file's aws_* keys with an AwsAuthService that had no
web identity token source, so aws_web_identity_token: "oidc/..." was
sent to AWS STS as the literal reference. VertexMessagesAuth now takes
the AwsAuthService the Python bridge already wires to the host secrets
for Bedrock (with_aws), so the reference is resolved as Python's
get_secret resolves it.
* fix(auth-gcp): retry the Vertex metadata server ping and project lookup as google-auth does
The GCE metadata ping is tried up to 3 times when the server cannot be
reached, and the project lookup up to 5 times on transport errors or
retryable statuses (408, 429, 500, 503, 504), waiting 1s and doubling
between tries, as google-auth's _metadata.ping and _metadata.get do.
* fix(auth-gcp): gather Vertex backwards-compat logins in vertex_messages/legacy
Move the certificate source, external_account_authorized_user refresh and
their shared token helper into vertex_messages/legacy, reached through a
small interface in legacy/mod.rs.
Add legacy/executable_source.rs: credential helper executables run as
google-auth's pluggable.py runs them (GOOGLE_EXTERNAL_ACCOUNT_* variables,
shell-style split with shlex, timeout_millis, a cached output_file read
under the credentials file size cap), with the subject token handed to
the SDK's ProgrammaticBuilder. Errors never carry the helper's output.
Add legacy/impersonation.rs: an impersonation URL off the SDK's default
host (Private Service Connect, other universes) is called directly with
the STS token, as google-auth does; the default host stays with the SDK.
The explicit AWS path passes universe_domain through.
Add bounded_file_source.rs: file-sourced subject tokens are read with the
capped spawn_blocking reader instead of the SDK's unbounded synchronous
read_to_string.
* fix(auth-gcp): keep the earlier Vertex key file credentials when a rewrite fails to load
When a vertex_credentials or ADC key file is rewritten and the new
contents do not load, log the credential failure and keep serving the
credentials that path loaded last, as Python does. A path that never
loaded fails as before. Other shared-loader callers are unchanged.
* fix(messages): keep main's connect-origin failure text after the merge
The merge of main kept this branch's older removal of the connect-failure
text rebuild (
|
||
|---|---|---|
| .. | ||
| cli | ||
| shared | ||
| strategies | ||
| __init__.py | ||
| __main__.py | ||
| AGENTS.md | ||
| conftest.py | ||