Enable the nilerr linter in golangci-lint - #1632
Draft
randomizedcoder wants to merge 2 commits into
Draft
Conversation
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>
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.
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
nilerrline.Enable the
nilerrlinternilerrcatches 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
dialUnixreturned(nil, nil)on a bad TLS config); enabling it guards against that class ofbug recurring.
Verified (with #1629's fix in place):
go build,go test ./..., andgolangci-lint run(pinned v2.11.4) all pass — and it has teeth: reintroducingthe unix bug makes
nilerrfire.Complements the govet + correctness linter set in #1631.
🤖 Generated with Claude Code