litellm/gateway
Yassin Kortam 4cae5431aa
fix(rust): ship the Rust extension where the gateway actually imports litellm from (#34202)
* fix(rust): ship the Rust extension where the gateway actually imports litellm from

The runtime sets PYTHONPATH=/app, so `import litellm` resolves to the source
tree copied by `COPY . .` rather than the wheel uv installs into /app/.venv.
maturin compiles the Rust extension as an artifact of that wheel build, so it
only ever lands under site-packages; the shadowing source tree wins at import
time and litellm.rust_bridge falls back to the Python implementation without
raising anything.

The staging Rust gateway has therefore never executed Rust: requests succeed,
return no x-litellm-rust marker, and the e2e suite would go green while
exercising the Python path.

Copy the extension next to the source it is imported from, and fail the build
when it is absent so a Rust image that cannot run Rust is never published.

* fix(rust): stop shadowing the installed litellm wheel with the source copy

The image carries two copies of the litellm package: the source tree COPY . .
puts at /app/litellm, and the wheel uv installs into /app/.venv. The runtime
sets PYTHONPATH=/app, so the source copy wins. maturin compiles the Rust
extension as an artifact of the wheel build, so it lives only in the copy that
loses, and loader.py returns None rather than raising when it cannot import it.
The gateway therefore serves every /messages request through Python while
looking perfectly healthy.

Drop the redundant source copy so import litellm resolves to the wheel; /app
stays importable for gateway. Assert at build time that the extension is
loadable, since build is the only point where 'this image must be able to run
Rust' is knowable.

Replaces an earlier version that copied the .so between the two copies: that
fixed the one artifact we noticed while leaving the duplication in place.
2026-07-22 15:00:00 -07:00
..
routes fix(gateway): keep the Prometheus /metrics Mount in the gateway route trim (#32317) 2026-07-07 18:36:38 +03:00
Dockerfile fix(rust): ship the Rust extension where the gateway actually imports litellm from (#34202) 2026-07-22 15:00:00 -07:00
main.py fix(gateway): keep the Prometheus /metrics Mount in the gateway route trim (#32317) 2026-07-07 18:36:38 +03:00