CVE-2025-25204: Go Nil Error Return On Empty Check

Returning an unassigned `err` variable inside an empty collection or nil check (`len(x) == 0` or `x == nil`) often results in inadvertently returning `nil` when a failure was intended. Ensure that you explicitly create and return a new error using `fmt.Errorf` or `errors.New` if this logic path represents a failure state.

Provally CuratedPublic repositoryMediumMedium confidenceVerifiedApache-2.0Goβ
greprules fetch cve-2025-25204-go-nil-error-return-on-empty-check --engine opengrep

Description

Returning an unassigned `err` variable inside an empty collection or nil check (`len(x) == 0` or `x == nil`) often results in inadvertently returning `nil` when a failure was intended. Ensure that you explicitly create and return a new error using `fmt.Errorf` or `errors.New` if this logic path represents a failure state.