fix(port): bracket IPv6 hosts in tcp address - #1060
Open
devsy-app[bot] wants to merge 4 commits into
Open
Conversation
## Package reviewed
`pkg/port` (tunneling/networking category).
## Issue found
`toAddress` built TCP listen addresses with plain string concatenation:
```go
Address: host + ":" + port
```
For IPv6 host literals this produces an ambiguous address that `net.Listen` rejects. For example, `host="::1"`, `port="8080"` yields `"::1:8080"`, and `net.Listen("tcp", "::1:8080")` fails with `listen tcp: address ::1:8080: too many colons in address`. Any port spec resolved against an IPv6 host was therefore unusable for binding a listener.
## Change
Use `net.JoinHostPort(host, port)` so IPv6 literals are bracketed (`[::1]:8080`, `[fe80::1]:443`) while IPv4 addresses and hostnames are unchanged.
```diff
- Address: host + ":" + port,
+ Address: net.JoinHostPort(host, port),
```
`net` (stdlib) is the only new import. No behavioral change for the IPv4/hostname path (verified by the existing test cases, which still expect `db:5432`, `database.internal:5432`, etc.).
## Tests
Updated the existing `IPv6 address` case (previously asserted the malformed `"::1:8080"` output) to the correct `"[::1]:8080"`, and added a second IPv6 case (`fe80::1` -> `[fe80::1]:443`) to lock in the bracketing end to end.
## Verification performed
- `task cli:format` — clean.
- `task cli:lint:ci` — 0 new issues.
- `task cli:test` — `pkg/port` passes (coverage 93.2%). The only failing package is `pkg/git` (`TestRepoClone*`), a known pre-existing failure on `origin/main` unrelated to this change (this change does not touch `pkg/git`).
- `go build ./pkg/port/...` and `go vet ./pkg/port/...` — pass.
- No proto changes; `task cli:build:grpc` not required.
This PR was created by an AI agent as part of an automated daily package review job.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
skevetter
marked this pull request as ready for review
August 17, 2026 05:43
Signed-off-by: Samuel K <skevetter@pm.me>
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.
Package reviewed
pkg/port(tunneling/networking category).Issue found
toAddressbuilt TCP listen addresses with plain string concatenation:For IPv6 host literals this produces an ambiguous address that
net.Listenrejects. For example,host="::1",port="8080"yields"::1:8080", andnet.Listen("tcp", "::1:8080")fails withlisten tcp: address ::1:8080: too many colons in address. Any port spec resolved against an IPv6 host was therefore unusable for binding a listener.Change
Use
net.JoinHostPort(host, port)so IPv6 literals are bracketed ([::1]:8080,[fe80::1]:443) while IPv4 addresses and hostnames are unchanged.net(stdlib) is the only new import. No behavioral change for the IPv4/hostname path (verified by the existing test cases, which still expectdb:5432,database.internal:5432, etc.).Tests
Updated the existing
IPv6 addresscase (previously asserted the malformed"::1:8080"output) to the correct"[::1]:8080", and added a second IPv6 case (fe80::1->[fe80::1]:443) to lock in the bracketing end to end.Verification performed
task cli:format— clean.task cli:lint:ci— 0 new issues.task cli:test—pkg/portpasses (coverage 93.2%). The only failing package ispkg/git(TestRepoClone*), a known pre-existing failure onorigin/mainunrelated to this change (this change does not touchpkg/git).go build ./pkg/port/...andgo vet ./pkg/port/...— pass.task cli:build:grpcnot required.This PR was created by an AI agent as part of an automated daily package review job.