fix(rlhf): percent-encode the IPv6 zone id in rollout base URLs - #10200
Open
Redemption-ZTX wants to merge 1 commit into
Open
Redemption-ZTX wants to merge 1 commit into
Redemption-ZTX wants to merge 1 commit into
Conversation
`format_host_for_url` wraps IPv6 addresses in brackets but copies the address
verbatim, so a scoped address such as `fe80::1%eth0` produced
`http://[fe80::1%eth0]:8000`. RFC 6874 requires the zone id to be
percent-encoded inside the brackets (`%25`); otherwise the URL carries `%et`,
which HTTP clients reject as a malformed percent-escape.
This is reachable because `vllm_client.py` resolves hostnames with
`resolve_hostname()` -- which supports IPv6 and can return a link-local
address with a zone id -- and then builds base URLs from the result:
self.base_urls = [f'http://{format_host_for_url(h)}:{p}'
for h, p in zip(hosts, server_ports)]
Only the single `%` separator is encoded, so a raw scoped address from
`resolve_hostname` is encoded exactly once.
Adds tests/general/test_ipv6_host_format.py covering IPv4/hostname
pass-through, plain IPv6 bracketing, zone-id encoding, the already-bracketed
form, and that the built URL still parses. The zone-id case fails without the
fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
format_host_for_urlwraps IPv6 addresses in brackets but copies the address verbatim, so a scoped address produces a URL with an unencoded zone id:RFC 6874 requires the zone id to be percent-encoded inside the brackets. Left unencoded, the URL carries
%et, which HTTP clients reject as a malformed percent-escape.Where it matters
format_host_for_urlhas a single call site, building the rollout base URLs from the caller-suppliedhosts:Any scoped (link-local) IPv6 reaching that list — e.g. from a config that addresses a node by its link-local address — yields a URL that HTTP clients reject.
Correction: an earlier version of this description claimed the address comes from
resolve_hostname()(vllm_client.py:91). That is wrong:resolve_hostname()sits in the other branch of the sameif/else, and its result only feedsself.hosts(used forbind_hostand the weight-sync connection at:239and:253), neverformat_host_for_url. The helper itself is still wrong on scoped input, which is what this PR fixes, but the reachability is narrower than I first wrote.Change
Only the single
%separator is encoded (host.partition('%')), so a raw scoped address is encoded exactly once. Addresses without a zone id are unaffected, andipaddress.IPv6Addressrejects the bracketed form, so an already-wrapped host is not wrapped twice.resolve_hostnameandis_valid_ipv6_addressare left untouched.Tests
Adds
tests/general/test_ipv6_host_format.py(9 cases): IPv4 and hostname pass-through, plain IPv6 bracketing, zone-id encoding, the already-bracketed form, and that the built URL still parses into the expected port and path.format_host_for_urlto the original body failstest_scoped_ipv6_zone_is_percent_encodedpre-commitclean (flake8, isort, yapf)No GPU required — this is pure
ipaddress/urllib.parselogic.