Skip to content

test: make nil-guard branches terminate to satisfy staticcheck SA5011 - #534

Merged
joshua-temple merged 1 commit into
mainfrom
test/nil-guard-terminate-sa5011
Jul 8, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
test/nil-guard-terminate-sa5011

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

The nightly release's Orchestrate validation failed on the release-path golangci-lint (v2.10.1 on the go1.26.5 toolchain): staticcheck SA5011 (possible nil pointer dereference) at test sites using the idiom if x == nil { t.Fatal(...) } followed by a deref of x. staticcheck does not always treat t.Fatal as terminating, so it sees the nil branch as able to fall through. This blocked the release-candidate from being cut, so the fleet never ran. (It surfaced only on the release path, a golangci-lint-action toolchain/cache sensitivity; the PR-gate lint and a locally built linter do not reproduce it.)

Fix

Add an explicit return as the last statement of each such nil guard so the nil path provably terminates. The return is unreachable at runtime because t.Fatal already exits the goroutine, so no test behavior changes. Applied to the three flagged sites plus every sibling with the same idiom so a later cut does not surface a new one.

Verification

Purely additive: 59 return insertions, 0 deletions, across 22 test files. go build ./... and go test ./... (2661 pass) clean; a golangci-lint v2.10.1 built with go1.26.5 reports 0 issues (no SA5011). No behavior, assertion, or format change.

The release-path golangci-lint (running on the go1.26.5 toolchain) flags staticcheck SA5011 (possible nil pointer dereference) at test sites that guard a pointer with 'if x == nil { t.Fatal(...) }' and then dereference it: staticcheck does not always treat t.Fatal as terminating, so it sees the nil branch as able to fall through. Add an explicit return as the last statement of each such guard so the nil path provably terminates. The return is unreachable at runtime because t.Fatal already exits the goroutine, so no test behavior changes; the edit is purely additive and only removes the lint ambiguity. Fixes the three flagged sites and every sibling with the same idiom so a later cut does not surface a new one.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit 0b23d06 into main Jul 8, 2026
20 checks passed
@joshua-temple
joshua-temple deleted the test/nil-guard-terminate-sa5011 branch July 8, 2026 17:31
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