Skip to content

chore(lint): enable nilerr in golangci-lint - #1776

Merged
mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:lint-wave3-nilerr
Sep 9, 2026
Merged

mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:lint-wave3-nilerr

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

nilerr flags if err != nil { return nil } — checking an error but returning nil (or another nil-valued error) instead of propagating it.

Part of #1755.

Scoping

Five findings: three real bugs fixed, two deliberate swallows (each now logged, one also carrying //nolint:nilerr).

  • platform/fabric/sdk/dig/sdk.go:175 — real bug: a config-lookup error for the default network's driver was conflated with a driver-name mismatch and silently ignored, which would have nil-pointer-dereferenced on c.Driver had the error path ever fired. Split the error check out and return it wrapped with errors.Wrapf.
  • platform/fabricx/core/vault/vault.go:436 — real bug: a genuine queryService.GetState RPC/network error was conflated with "no committed value" and silently swallowed. Split it out and return it wrapped with errors.Wrapf.
  • platform/fabricx/core/vault/vault.go:441 — deliberate: mds.GetFieldMapping is documented to return an error on both a genuine failure and an ordinary miss (see its comment in platform/fabric/core/generic/transaction/services.go), so callers must treat any error as "no mapping". Documented that reasoning in a comment at the call site and added a debug log line that wasn't there before — logging err in the block is enough for nilerr to stop reporting, so no //nolint is needed here.
  • platform/view/services/config/config_util.go:58 — real bug: byteSizeDecodeHook already returns a hard "overflows uint32" error a few lines below for a related overflow case; the ParseUint failure a few lines above (uint64 overflow before the shift) was silently deferred to the default decoder instead of being reported the same way. Now returns the error wrapped with errors.Wrapf.
  • integration/fabric/events/views/events.go:49 — deliberate: this test callback captures event.Err into the outer eventError variable for the test's own assertions; the callback's own error return only triggers a log line in the listener goroutine (RegisterChaincodeEvents) and has no bearing on the test outcome. Added a debug log line for the error and //nolint:nilerr with that reasoning.

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-3 PR. It should merge cleanly regardless of the order the other wave-3 PRs land in.

@github-actions

github-actions Bot commented Sep 8, 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 -- Heads up! The following commits don't have a verified GPG signature:

  • 42d9a37 chore(lint): enable nilerr in golangci-lint

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ 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 8, 2026
@mbrandenburger mbrandenburger added this to the 26Q3 milestone Sep 8, 2026
@mbrandenburger mbrandenburger mentioned this pull request Sep 8, 2026
28 of 29 tasks

@SaidAltury-ibm SaidAltury-ibm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@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

Enables nilerr, which flags `if err != nil { return nil }`. It reported
5 findings: 3 real bugs fixed, 2 deliberate swallows (each now logged).
One of the two also carries //nolint:nilerr; the other needs none, because
logging err in the block is enough for nilerr to stop reporting. No
deferrals.

- platform/fabric/sdk/dig/sdk.go:175 - real bug: a config lookup error
  for the default network's driver was conflated with a driver-name
  mismatch and silently ignored (and would have nil-pointer-dereferenced
  on c.Driver had the error path ever fired). Split the error check out
  and return it wrapped with errors.Wrapf.
- platform/fabricx/core/vault/vault.go:436 - real bug: a genuine
  queryService.GetState RPC/network error was conflated with "no
  committed value" and silently swallowed. Split it out and return it
  wrapped with errors.Wrapf.
- platform/fabricx/core/vault/vault.go:441 - deliberate: mds.GetFieldMapping
  is documented to return an error on both a genuine failure and an
  ordinary miss (see its comment in
  platform/fabric/core/generic/transaction/services.go), so callers
  must treat any error as "no mapping". Documented that reasoning in a
  prose comment at the call site and added a debug log line (there was
  none before). No //nolint is needed here: logging err in the block is
  enough for nilerr to stop reporting.
- platform/view/services/config/config_util.go:58 - real bug:
  byteSizeDecodeHook already returns a hard "overflows uint32" error a
  few lines below for a related overflow case; the ParseUint failure a
  few lines above (uint64 overflow before the shift) was silently
  deferred to the default decoder instead of being reported the same
  way. Now returns the error wrapped with errors.Wrapf.
- integration/fabric/events/views/events.go:49 - deliberate: this test
  callback captures event.Err into the outer eventError variable for
  the test's own assertions; the callback's own error return only
  triggers a log line in the listener goroutine (RegisterChaincodeEvents)
  and has no bearing on the test outcome. Added a debug log line for the
  error (there was none) and //nolint:nilerr with that reasoning.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger
mbrandenburger merged commit a29b75b into hyperledger-labs:main Sep 9, 2026
40 of 41 checks passed
@mbrandenburger
mbrandenburger deleted the lint-wave3-nilerr branch September 9, 2026 06:58
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