[Repo Assist] test(cmd): cover net.Listen failure branch in setupTLSListener - #13709
Conversation
Adds TestSetupTLSListener_ListenFailure, which occupies the target address before calling setupTLSListener so the underlying net.Listen call fails deterministically. This previously-untested branch (the early-return "failed to listen on %s" error path) was the only uncovered statement in setupTLSListener (96.0% -> should be 100%). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The test must keep the ephemeral listener open to avoid a port-reacquisition race.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds coverage for the net.Listen failure path in setupTLSListener.
Changes:
- Adds a test using an occupied loopback address.
- Verifies the wrapped error, nil listener, and disabled TLS state.
| File | Description |
|---|---|
internal/cmd/startup_test.go |
Adds listener-failure coverage; address reservation is vulnerable to a race. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Notes:
|
🔒 mcpg Read-Only Stress — gvisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write leaked in any part.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot merge main and fix failing lint checks https://github.com/github/gh-aw-mcpg/actions/runs/35870575800/job/107213267887?pr=13709 |
…est-coverage-setuptlslistener-listenfailure-20260923-3a7ad4e4e584c2e1 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Merged |

🤖 This is an automated PR from Repo Assist, an AI assistant for this repository.
What
Adds
TestSetupTLSListener_ListenFailureininternal/cmd/startup_test.go, covering the previously-untested error branch ofsetupTLSListenerwhere the underlyingnet.Listen("tcp", listenAddr)call fails (e.g. because the address is already in use).Why
While looking for test-coverage gaps (Task 9),
go tool cover -funcshowedsetupTLSListenerat 96.0% — the only uncovered statement was the early-return"failed to listen on %s"error path. All other branches of this function (TLS validation errors, plain HTTP listener, TLS listener, mTLS listener, and the "listener closed on TLS setup failure" path) were already exercised by existing tests.Approach
The new test occupies a loopback address with a real listener first (mirroring the existing
occupiedAddrpattern already used ininternal/cmd/delegation_test.go), then callssetupTLSListeneragainst that same address and asserts the wrapped error, nil listener, andtlsEnabled == false.Test Status
go build ./...— cleango vet ./...— cleangofmt -l— cleanmake agent-finished(build + lint + full unit test suite, including Rust guard tests) — all passinternal/cmdcoverage: 91.8% → 92.0%;setupTLSListener: 96.0% → 100.0%No production code was changed — this is a test-only addition.
Warning
Firewall blocked 5 domains
The following domains were blocked by the firewall during workflow execution:
api.github.comexample.comnonexistent.localslow.example.comthishostdoesnotexist12345.com[!TIP]
api.github.comis blocked because GitHub API access uses the built-in GitHub tools by default. Instead of addingapi.github.comtonetwork.allowed, usetools.github.mode: gh-proxyfor direct pre-authenticated GitHub CLI access without requiring network access toapi.github.com:See GitHub Tools for more information on
gh-proxymode.To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run