Skip to content

chore(lint): enable contextcheck in golangci-lint - #1783

Merged
mbrandenburger merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:lint-wave4-contextcheck
Sep 9, 2026
Merged

mbrandenburger merged 2 commits into
hyperledger-labs:mainfrom
mbrandenburger:lint-wave4-contextcheck

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

contextcheck flags a function that receives a context.Context but doesn't pass it through to a call that itself takes one — instead using context.Background()/context.TODO(), a nested detached context, or (missed) propagation.

Part of #1755.

Scoping

43 findings, all in the root module. 2 were genuine bugs (a stray context.TODO() and an unused-ctx test double) and are threaded through with no behavior change. The other 41 are deliberate context detachment — background work, pooled connections/streams, and trace-correlation logging that must outlive or not derive from the call that happens to trigger them — and are suppressed with a reason.

  • 24 findings in the p2p comm layer (cached/pooled websocket sub-connections, streams, and sessions whose lifecycle is independent of any single call, regression-tested by context_detachment_test.go) share one config exclusion in .golangci.yml rather than 24 scattered //nolints.
  • 17 findings elsewhere (nil-ctx fallbacks, trace-link/log correlation against a different originating context, shared broadcast/delivery streams, uncancellable error reporting) get individual //nolint:contextcheck comments, each naming the specific reason.

No deferred or ambiguous findings — every site traced back to an already-latent, often already-documented design rationale.

Verification

make checks exits 0 across all four modules.

Note for reviewers

This branch is independent — rooted directly on current main, not stacked on any other wave-4 PR. It should merge cleanly regardless of the order the other wave-4 PRs land in.

Enabling contextcheck surfaced 43 findings, all in the root module.
2 were genuine bugs (a stray context.TODO() and an unused-ctx test
double) and are threaded through with no behavior change. The other
41 are deliberate context detachment - background work, pooled
connections/streams, and trace-correlation logging that must outlive
or not derive from the call that happens to trigger them - and are
suppressed with a reason:

- 24 findings in the p2p comm layer (cached/pooled websocket
  sub-connections, streams, and sessions whose lifecycle is
  independent of any single call, regression-tested by
  context_detachment_test.go) share one config exclusion in
  .golangci.yml rather than 24 scattered nolints.
- 17 findings elsewhere (nil-ctx fallbacks, trace-link/log
  correlation against a different originating context, shared
  broadcast/delivery streams, uncancellable error reporting) get
  individual //nolint:contextcheck comments, each naming the
  specific reason.

No DEFERRED or AMBIGUOUS findings: every site traced back to an
already-latent, often already-documented design rationale.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Hey @mbrandenburger 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


✅ GPG Signature -- All commits have verified GPG signatures. Locked and loaded!


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


❌ Issue Link -- This PR is not linked to any issue.

Please reference an issue using a closing keyword (e.g. Fixes #123) and ensure the issue is assigned to you. Every PR needs a home!


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs revision The pull request requires changes from the author before it can be reviewed or merged label Sep 9, 2026
@mbrandenburger mbrandenburger added this to the 26Q3 milestone Sep 9, 2026
@mergify

mergify Bot commented Sep 9, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Hi @mbrandenburger 👋 — the recent merge of PR #1782 has introduced a merge conflict in this PR. Please resolve the merge conflict so that this PR can be reviewed again. Thank you!

Signed-off-by: Marcus Brandenburger <mbrandenburger@users.noreply.github.com>
@mbrandenburger
mbrandenburger merged commit 2fa690e into hyperledger-labs:main Sep 9, 2026
45 checks passed
@mbrandenburger
mbrandenburger deleted the lint-wave4-contextcheck branch September 9, 2026 08:14
@mbrandenburger mbrandenburger mentioned this pull request Sep 9, 2026
28 of 29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants