Repository navigation
fix(python): bracket IPv6 hosts in managed server URLs - #3003
Conversation
`ManagedServer` built its readiness URL and its OpenAI base URL as
`http://{host}:{port}/…`. With an IPv6 literal such as `::1` that is
`http://::1:8080/health`, which httpx rejects (`InvalidURL: Invalid port`),
so `LLM(model, host="::1")` failed during startup although the server was
given a valid `--host`.
Both URLs now come from one origin that brackets a raw IPv6 literal. The
host passed to the server command line is unchanged, and an already
bracketed literal, an IPv4 address, a hostname and a Unix socket are
formatted as before.
|
Thanks for the fix. Reviewed against #3002: I merged current |
Summary
LLM(model, host="::1")failed during startup withhttpx.InvalidURL: the manager put the raw IPv6 literal into its readiness and base URLs. Both URLs now come from one origin that brackets a raw IPv6 literal. The--hostargument passed to the server is unchanged.Related issues
Closes #3002.
Type of change
fix— bug fixCause
ManagedServer.base_urlandManagedServer._health_url(python/src/mlxcel/_server.py) formattedf"http://{self.host}:{self.port}/…", which for::1ishttp://::1:18080/….Change
ManagedServer._http_origin(new):http://mlxcelfor a Unix socket as before; otherwisehttp://{host}:{port}with the host bracketed when it contains:and is not bracketed already.base_urland_health_urlappend/v1and/healthto it._build_commandis untouched: the server still receives the host as the caller gave it.::1and with[::1], through shutdown.python/tests/fake_server.pycan now bindAF_INET6. The lifecycle cases skip on a host that cannot bind the IPv6 loopback; they ran here.Before / after
Linux aarch64, Python 3.12.3, real loopback HTTP, no model.
mainwith the new tests-m "not e2e")The four failures on
mainare the two raw-IPv6 URL checks and the two raw-IPv6 lifecycles (httpx.InvalidURL). The bracketed, IPv4, hostname and Unix-socket cases pass before and after.Test plan
Run on this PR's source (one commit on
955335a38, treeeab5f3ba11d9).python -m pytest -m "not e2e"inpython/with both dependency pairs above: 61 passed, 2 deselected each; none of the IPv6 cases skippedmain: 4 failed, 6 passed with both pairsruff check python,ruff format --check python,mypy python/src: passmlxcel serveon an IPv6 address: not run. The lifecycle cases use the fake server; the Rust listener's own IPv6 handling is not touchedNotes for reviewers
[::1]keeps working and is not bracketed twice.Checklist
docs/: not needed// Used by: ...comments: not applicable (Python).envfiles committed