Skip to content

Commit 5dc137c

Browse files
authored
Use netloc from urlparse to specify the host (#79)
This is because `netloc` is formatted to be the network location, and wraps ipv6 in square brackets, which we lose if we just use the `host` field. `netloc` also contains the port if a port was in the original uri. We need to append the default port only if the original uri didn't have a port. This fixes an issue when creating a grpc Channel with ipv6 addresses.
2 parents cc16989 + 13f223e commit 5dc137c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
## Bug Fixes
1616

17-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
17+
- Fixes a bug in creating grpc channels from ipv6 URIs.

src/frequenz/client/base/channel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def parse_grpc_uri(
110110

111111
options = _parse_query_params(uri, parsed_uri.query)
112112

113-
host = parsed_uri.hostname
114-
port = parsed_uri.port or defaults.port
115-
target = f"{host}:{port}"
113+
target = (
114+
parsed_uri.netloc if parsed_uri.port else f"{parsed_uri.netloc}:{defaults.port}"
115+
)
116116

117117
ssl = defaults.ssl.enabled if options.ssl is None else options.ssl
118118
if ssl:

0 commit comments

Comments
 (0)