Repository navigation
fix: resolve the ?addr=:port shorthand against the primary host - #1025
Merged
rueian merged 2 commits intoAug 30, 2026
Merged
Conversation
rueian
reviewed
Aug 30, 2026
Co-authored-by: Rueian <[email protected]>
rueian
approved these changes
Aug 30, 2026
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.
Running two Redis instances on one box is common enough, and
?addr=:6380is the shorthand for pointing at the second one. Do that against a primary that has its own port and you get back an address nothing can dial:Thats v1.0.77. A port-only
?addr=has no host of its own, so it falls back tou.Host, which still carries the primarys:6379, and the whole thing gets bracketed as though it were an IPv6 literal. It only goes wrong when the primary has an explicit port, so nearly always. And because it fails at connect time rather than at parse time, it reads like DNS or a firewall.Giving that fallback the host the primary already resolved to leaves the primary address and the TLS
ServerNamealone. I diffed the parse output over a spread of URLs, bracketed and unbracketed IPv6 andunix://included, and only the?addr=entries move.?addr=hostwith no port I've left alone, its still resolving to the primary's host insted ofhost:6379. Most of the diff is the two test cases, copying the shape of the?addr=assertion above them.Note
Low Risk
Small, localized change to Redis URL parsing with targeted tests; wrong addresses fail at dial time but do not affect security-sensitive paths.
Overview
Fixes broken multi-instance Redis URLs when the primary includes an explicit port and extra nodes use the
?addr=:portshorthand (e.g.redis://cache:6379?addr=:6380).In
ParseURL’sparseAddrhelper, the host fallback for port-onlyaddrvalues now usesu.Hostname()instead ofu.Host, so the resolved host iscache(or[::1]for IPv6) rather than the fullhost:portstring that was incorrectly joined and bracketed as[cache:6379]:6380. Primary address and TLSServerNamebehavior stay the same; only?addr=entries that omit a host change.Tests cover hostname+port and bracketed IPv6 primaries with
?addr=:6380.Reviewed by Cursor Bugbot for commit 28879b5. Bugbot is set up for automated code reviews on this repo. Configure here.