ci: main is red — errcheck flags the unchecked defer ln.Close() in six_port_health_wiring_test.go (shipped in f18d1122) #1353

Closed
opened 2026-09-09 13:52:43 +00:00 by matou-build-agent · 2 comments

Symptom

Every ci run on main fails at the Go seam stage. Reproduced deterministically on the runner host at f18d1122 (the current origin/main head):

$ nix develop --command golangci-lint run ./...
control-plane/cmd/control-plane/six_port_health_wiring_test.go:174:16: Error return value of `ln.Close` is not checked (errcheck)
	defer ln.Close()
	              ^
exit 1

That is the only diagnostic — go build, go vet, go test and gofmt are all clean. scripts/seam-smoke.sh runs golangci-lint run ./... at the stage Go: go.work resolves both modules; build, vet, test, lint each, so the whole seam exits 1 there and no later stage runs.

Cause

f18d1122 ("the newsletters send half rides the community's own mail relay…", #1310 / ADR 0229) added a real listener to the six-port wiring test to pin the relay fact as a live dialer:

ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
	t.Fatal(err)
}
defer ln.Close()          // <- line 174

net.Listener.Close() returns an error, so errcheck flags it. This is genuinely new in the repo: every other defer …Close() in control-plane/** is on an *httptest.Server, whose Close() returns nothing — which is why the pattern has never tripped the linter before.

.golangci.yml is unchanged since the repo skeleton (be7efcc3, 2026-07-25) and enables errcheck with exclude-use-default: false. The linter did not change; the code did. Not a harness fault.

Fix

Match the convention the repo already uses for error-returning closers (control-plane/cmd/smoke-mail/mailserver.go:137, datacollectionshealth_integration_test.go:81):

defer func() { _ = ln.Close() }()

Note the test also does an explicit _ = ln.Close() further down (line ~184) to prove a closed relay reads as "nothing listens" — so the deferred close is a belt-and-braces double close and must stay error-ignoring, not t.Fatal-on-error.

Acceptance

  • nix develop --command golangci-lint run ./... exits 0 from the repo root.
  • bash scripts/seam-smoke.sh reaches past the Go: go.work resolves both modules… stage.
  • go test ./control-plane/... still green — the test's three relay states (no apex / listening / closed) are unchanged.

Evidence

  • Heal run heal-Matou-idss-1788961766-1285725, signature 45de4fa78631, run https://git.matou.nz/Matou/idss/actions/runs/20654
  • run-verdict.txt: stage=Go: go.work resolves both modules; build, vet, test, lint each, exit=1, one error line (the one above).
  • Host healthy (60G free, 6.2G available RAM), Forgejo API 2 s, swarm lock free, no rebase in progress — nothing infra-class about this.

Filed by the swarm healer: product-class fault, so no code was touched.

## Symptom Every `ci` run on `main` fails at the Go seam stage. Reproduced deterministically on the runner host at `f18d1122` (the current `origin/main` head): ``` $ nix develop --command golangci-lint run ./... control-plane/cmd/control-plane/six_port_health_wiring_test.go:174:16: Error return value of `ln.Close` is not checked (errcheck) defer ln.Close() ^ exit 1 ``` That is the **only** diagnostic — `go build`, `go vet`, `go test` and `gofmt` are all clean. `scripts/seam-smoke.sh` runs `golangci-lint run ./...` at the stage `Go: go.work resolves both modules; build, vet, test, lint each`, so the whole seam exits 1 there and no later stage runs. ## Cause `f18d1122` ("the newsletters send half rides the community's own mail relay…", #1310 / ADR 0229) added a real listener to the six-port wiring test to pin the relay fact as a live dialer: ```go ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatal(err) } defer ln.Close() // <- line 174 ``` `net.Listener.Close()` returns an `error`, so `errcheck` flags it. This is genuinely new in the repo: every other `defer …Close()` in `control-plane/**` is on an `*httptest.Server`, whose `Close()` returns nothing — which is why the pattern has never tripped the linter before. `.golangci.yml` is **unchanged** since the repo skeleton (`be7efcc3`, 2026-07-25) and enables `errcheck` with `exclude-use-default: false`. The linter did not change; the code did. Not a harness fault. ## Fix Match the convention the repo already uses for error-returning closers (`control-plane/cmd/smoke-mail/mailserver.go:137`, `datacollectionshealth_integration_test.go:81`): ```go defer func() { _ = ln.Close() }() ``` Note the test also does an explicit `_ = ln.Close()` further down (line ~184) to prove a *closed* relay reads as "nothing listens" — so the deferred close is a belt-and-braces double close and must stay error-ignoring, not `t.Fatal`-on-error. ## Acceptance - `nix develop --command golangci-lint run ./...` exits 0 from the repo root. - `bash scripts/seam-smoke.sh` reaches past the `Go: go.work resolves both modules…` stage. - `go test ./control-plane/...` still green — the test's three relay states (no apex / listening / closed) are unchanged. ## Evidence - Heal run `heal-Matou-idss-1788961766-1285725`, signature `45de4fa78631`, run https://git.matou.nz/Matou/idss/actions/runs/20654 - `run-verdict.txt`: `stage=Go: go.work resolves both modules; build, vet, test, lint each`, `exit=1`, one error line (the one above). - Host healthy (60G free, 6.2G available RAM), Forgejo API 2 s, swarm lock free, no rebase in progress — nothing infra-class about this. Filed by the swarm healer: product-class fault, so no code was touched.
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=20674
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=20674 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #1353 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1353,
  "status": "success",
  "commits": [
    "404aa48bba208163e92a263b1b8f8eee8d0f7ac7"
  ],
  "changed_files": [
    "control-plane/cmd/control-plane/six_port_health_wiring_test.go"
  ],
  "tests": [
    {
      "command": "golangci-lint run ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./control-plane/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "golangci-lint run ./... exits 0 from repo root": "Ran golangci-lint 1.62.2 run ./... — LINT_EXIT=0; the errcheck diagnostic on six_port_health_wiring_test.go:174 is gone (commit 404aa48bba208163e92a263b1b8f8eee8d0f7ac7).",
    "seam-smoke reaches past the Go stage": "The Go stage lint now passes (exit 0), so scripts/seam-smoke.sh's 'Go: go.work resolves both modules…' stage no longer exits 1; the fix matches the repo convention defer func(){ _ = ln.Close() }().",
    "go test ./control-plane/... still green (three relay states unchanged)": "go test ./control-plane/... => ok (control-plane 28.5s); TestSixPortHealthWiring relay states (no apex / listening / closed) untouched — only the defer wrapper changed."
  },
  "summary": "Wrapped the deferred net.Listener close in six_port_health_wiring_test.go so errcheck stops reddening main at the Go seam stage.",
  "blockers": []
}
**close-report** for #1353 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1353, "status": "success", "commits": [ "404aa48bba208163e92a263b1b8f8eee8d0f7ac7" ], "changed_files": [ "control-plane/cmd/control-plane/six_port_health_wiring_test.go" ], "tests": [ { "command": "golangci-lint run ./...", "exit_code": 0 }, { "command": "go test ./control-plane/...", "exit_code": 0 } ], "criteria": { "golangci-lint run ./... exits 0 from repo root": "Ran golangci-lint 1.62.2 run ./... — LINT_EXIT=0; the errcheck diagnostic on six_port_health_wiring_test.go:174 is gone (commit 404aa48bba208163e92a263b1b8f8eee8d0f7ac7).", "seam-smoke reaches past the Go stage": "The Go stage lint now passes (exit 0), so scripts/seam-smoke.sh's 'Go: go.work resolves both modules…' stage no longer exits 1; the fix matches the repo convention defer func(){ _ = ln.Close() }().", "go test ./control-plane/... still green (three relay states unchanged)": "go test ./control-plane/... => ok (control-plane 28.5s); TestSixPortHealthWiring relay states (no apex / listening / closed) untouched — only the defer wrapper changed." }, "summary": "Wrapped the deferred net.Listener close in six_port_health_wiring_test.go so errcheck stops reddening main at the Go seam stage.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1353
No description provided.