litellm/tests/unit/proxy/decisions_endpoints
Mateo Wang 9da09d70b8
fix(decisions): accept multipart image uploads on /v1/systemone (#55352)
* fix(decisions): accept multipart image uploads on /v1/systemone

* fix(decisions): run header checks and auth before reading multipart systemone bodies

* fix(decisions): send multipart uploads to the model auth chose

A multipart /v1/systemone request built its upstream body from the form it parsed before auth, so a model rewrite made during auth, such as a key's budget fallback, never reached the provider. The endpoint now reads the post-auth parsed body and inlines the uploaded images into it.

* fix(decisions): accept long SDK request parts and point urlencoded JSON at JSON

The TypeSafe SDK sends its request JSON as a multipart part with no filename, so Starlette's 1 MiB cap on such parts refused long-context image calls with a 400. /v1/systemone now reads its form with no per-part cap, leaving the operator's request size limit as the only bound, as for a JSON body.

A JSON body sent with curl's default urlencoded content type got a multipart error. Only multipart bodies take the form path now, so it gets "the body must be JSON" like /v1/decisions.

* fix(auth): let a team member's budget fallback reach multipart /v1/systemone uploads

The team member per-model budget fallback skipped every multipart request,
so an SDK image upload over a member's budget got the budget error while the
same JSON request moved to the fallback model. /v1/systemone marks its parsed
form as the served body, so the fallback now applies to it like the key-level
fallback and the alias rewrites already do

* fix(systemone): keep the caller's own form metadata and refuse repeated part names

Auth merges header and key tags into the body it checks, and the multipart
endpoint read that same body back, so its requester metadata listed tags the
caller never sent while a JSON body kept only its own. Auth now gets its own
copy of the parsed form, and the endpoint keeps the caller's form with only
the model auth chose.

Two file parts with the same name kept only the last file, so the second
asset went upstream with an empty image. A repeated part name now answers 400
before any pre-call hook runs.

* fix(systemone): take image parts sent without a filename, name OTel traces from the request part, document multipart in OpenAPI

An asset part sent without a filename now reaches TypeSafe with its exact bytes, as TypeSafe itself takes it, instead of a 400

With LITELLM_OTEL_V2, metadata.trace_id inside the multipart request part now names the trace on /v1/systemone and /systemone, like the JSON body

The OpenAPI spec for both routes now lists the multipart form next to the JSON body

* fix(systemone): keep image bytes under a declared charset, name OTel traces from the request part behind a root path

An image part sent without a filename now reaches TypeSafe byte for byte when the request declares a charset such as windows-1252 or iso-8859-15, since the proxy reverses Starlette's decode with that charset before its Latin-1 fallback

With SERVER_ROOT_PATH set, metadata.trace_id in the multipart request part now names the trace, and every route picks its trace metadata field from the route the proxy dispatches on

* fix(systemone): document upload assets in the multipart schema, keep part bytes on any codec error

* test(systemone): annotate the swagger test's locals as Final
2026-12-03 21:27:26 +00:00
..
__init__.py feat(decisions): add unified /v1/decisions endpoint for Jev-compatible providers (#44236) 2026-10-03 17:38:38 +00:00
test_endpoints.py fix(decisions): accept multipart image uploads on /v1/systemone (#55352) 2026-12-03 21:27:26 +00:00