You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This linter flags bare type assertions v.(T) that don't use comma-ok (v, ok := x.(T)). Bare assertions panic at runtime on type mismatch — they are Go's equivalent of an unchecked cast.
Why This Matters
With forcetypeassert disabled, there is no CI protection against new bare type assertions introduced by contributors. A missing comma-ok in error handling, context value extraction, or interface dispatch becomes a latent crash that only triggers in production.
There are 44 bare type assertions from sync.Pool.Get() results (see #2231). These are controlled but unprotected by CI.
There are also safe comma-ok assertions in the codebase (e.g., tcpdialer.go:432, http.go:1021, server.go:858, peripconn.go:125) — showing the codebase already uses both patterns inconsistently.
Suggested Fix
Remove forcetypeassert from the disable list in .golangci.yml
Description
The
forcetypeassertlinter is explicitly disabled in.golangci.yml(line 15):This linter flags bare type assertions
v.(T)that don't use comma-ok (v, ok := x.(T)). Bare assertions panic at runtime on type mismatch — they are Go's equivalent of an unchecked cast.Why This Matters
With
forcetypeassertdisabled, there is no CI protection against new bare type assertions introduced by contributors. A missing comma-ok in error handling, context value extraction, or interface dispatch becomes a latent crash that only triggers in production.This is the exact category of bug that caused:
RequestCtxpanic from poolperIPConnCounterpanic on shutdownRequestCtxpanicCurrent Bare Assertions in Codebase
There are 44 bare type assertions from
sync.Pool.Get()results (see #2231). These are controlled but unprotected by CI.There are also safe comma-ok assertions in the codebase (e.g.,
tcpdialer.go:432,http.go:1021,server.go:858,peripconn.go:125) — showing the codebase already uses both patterns inconsistently.Suggested Fix
forcetypeassertfrom thedisablelist in.golangci.yml//nolint:forcetypeassertannotations to the known-safe pool assertions (the 44 instances from safety: 44 bare type assertions from sync.Pool without comma-ok — panics on pool corruption #2231)This follows the same pattern as the existing
//nolint:errcheckand// #nosec G115annotations already in the codebase.Impact