Skip to content

Enable the nilerr linter in golangci-lint - #1632

Draft
randomizedcoder wants to merge 2 commits into
prometheus:masterfrom
randomizedcoder:add-nilerr
Draft

Enable the nilerr linter in golangci-lint#1632
randomizedcoder wants to merge 2 commits into
prometheus:masterfrom
randomizedcoder:add-nilerr

Conversation

@randomizedcoder

Copy link
Copy Markdown
Contributor

⚠️ Draft — depends on #1629; do not merge before it lands.

While #1629 is open, this PR's diff also shows that unix.go fix (it is the
merge base). Once #1629 merges, this reduces to the single nilerr line.

Enable the nilerr linter

nilerr catches functions that check an error and then return a different
(often nil) error, silently swallowing the real one. It found the dropped
TLS-config error in the unix prober fixed in #1629 (where dialUnix returned
(nil, nil) on a bad TLS config); enabling it guards against that class of
bug recurring.

Verified (with #1629's fix in place): go build, go test ./..., and
golangci-lint run (pinned v2.11.4) all pass — and it has teeth: reintroducing
the unix bug makes nilerr fire.

Complements the govet + correctness linter set in #1631.

🤖 Generated with Claude Code

randomizedcoder and others added 2 commits July 20, 2026 08:14
On a TLS-config failure, dialUnix logged and returned the wrong variable —
err, which is nil at that point — instead of tlsErr. The error was silently
swallowed: dialUnix returned (nil, nil), so a caller would proceed with a
nil connection rather than seeing the configuration error.

Return (and log) tlsErr so the failure surfaces.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: randomizedcoder <dave.seddon.ca@gmail.com>
nilerr catches functions that check an error and then return a different
(often nil) error, silently swallowing the real one. It found the dropped
TLS-config error in the unix prober that the parent commit fixes; enabling
it guards against that class of bug recurring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: randomizedcoder <dave.seddon.ca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant