Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.api-usage

Pass a real context.Context

Context-accepting calls should not receive a literal `nil` as their first argument.

#Metadata

Rule ID
go.correctness.nil-context-passed
Severity
medium
Confidence
0.9
Languages
go
Presets
strict
Stability
stable
Applies to
block
Tags
correctness, go, rules-catalog

#Why it matters

Standard library functions that take `context.Context` panic or skip cancellation semantics when called with `nil`. Use `context.Background()`, `context.TODO()`, or a propagated context instead.

#Remediation

Use `context.Background()`, `context.TODO()`, or a propagated context value instead of `nil`.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/go/go.correctness.nil-context-passed.rule.yaml.