Skip to content

CI: enable error-handling linters and fix a few bugs#6479

Merged
algorandskiy merged 7 commits intoalgorand:masterfrom
cce:fix-error-lint
Oct 31, 2025
Merged

CI: enable error-handling linters and fix a few bugs#6479
algorandskiy merged 7 commits intoalgorand:masterfrom
cce:fix-error-lint

Conversation

@cce
Copy link
Copy Markdown
Contributor

@cce cce commented Oct 31, 2025

Summary

While upgrading to golangci-lint v2.6.0 after #6474 and #6473, I enabled some more safety linters (not style linters) to see if anything turned up, and found these error-handling bugs spotted by the govet liter's nilness check, the nilnesserr linter, and the testifylint linter's error-is-as check.

Test Plan

Existing tests should pass.

@cce cce added the Bug-Fix label Oct 31, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.29%. Comparing base (495da8c) to head (9aaa7f6).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
network/p2pNetwork.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6479      +/-   ##
==========================================
- Coverage   47.44%   47.29%   -0.16%     
==========================================
  Files         666      659       -7     
  Lines       88310    88225      -85     
==========================================
- Hits        41900    41726     -174     
- Misses      43649    43733      +84     
- Partials     2761     2766       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread agreement/pseudonode_test.go
Comment thread catchup/universalFetcher_test.go
Comment thread ledger/ledger_test.go
Comment thread data/txHandler_test.go
@cce cce changed the title CI: enable nilness, nilnesserr linters and fix a couple of error-handling bugs CI: enable error-handling linters and fix a few bugs Oct 31, 2025
algorandskiy
algorandskiy previously approved these changes Oct 31, 2025
@cce
Copy link
Copy Markdown
Contributor Author

cce commented Oct 31, 2025

I just went through and ran golangci-lint run --enable-only govet --config .golangci.yml --new-from-rev="" to get the nilness errors in the whole codebase, and fixed those too. nilnesserr came up clean. testifylint error-is-as found another spot where the type was not correctly being asserted.

Comment thread test/netperf-go/puppeteer/puppeteer.go
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

LGTM except the local.go changes

Comment thread cmd/tealdbg/local.go
@cce cce requested review from algorandskiy and Copilot and removed request for gmalouf and jannotti October 31, 2025 19:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades golangci-lint to v2.6.0 and enables several error-handling focused linters (nilness, nilnesserr, and testifylint's error-is-as check) to improve code safety. The changes fix multiple error-handling bugs discovered by these linters across the codebase.

Key changes:

  • Fixes incorrect error variable usage in error handling and logging
  • Replaces incorrect assertion methods with proper error-checking assertions
  • Removes unreachable or incorrectly conditioned error-handling code

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.golangci.yml Enables new linters (nilness, nilnesserr, testifylint) for improved error handling checks
.github/workflows/reviewdog.yml Updates golangci-lint version to v2.6.0
scripts/buildtools/versions Updates golangci-lint dependency version to v2.6.0
network/p2pNetwork.go Fixes error variable mismatch in logging statement
test/netperf-go/puppeteer/puppeteer.go Restructures error handling to properly check and handle errors from metric operations
test/e2e-go/features/participation/overlappingParticipationKeys_test.go Removes unreachable error handling code
test/e2e-go/features/catchup/catchpointCatchup_test.go Removes redundant nil check and fixes error message formatting
netdeploy/remote/nodecfg/nodeConfigurator.go Removes unreachable error handling code
ledger/catchupaccessor.go Fixes const declaration syntax (moved outside closing paren)
cmd/algorelay/relayCmd.go Removes unreachable error handling code
cmd/dispenser/server.go Fixes incorrect error usage in HTTP response
cmd/tealdbg/local.go Removes unnecessary nil checks before logging errors
util/db/dbutil_test.go Replaces require.Error with require.ErrorIs for proper error comparison
ledger/txtail_test.go Replaces require.Truef(errors.As) with require.ErrorAsf
ledger/store/trackerdb/sqlitedriver/sql_test.go Replaces require.False(errors.As) with require.NotErrorAs
ledger/ledger_test.go Replaces require.True(errors.As) with require.ErrorAs and fixes error variable check
ledger/eval/prefetcher/prefetcher_test.go Replaces require.True(errors.Is) with require.ErrorIs
data/txHandler_test.go Replaces require.Error with require.ErrorIs for proper error comparison
daemon/algod/api/server/common/test/handlers_test.go Changes error assertion from comparing error objects to comparing error strings
crypto/merklesignature/merkleSignatureScheme_test.go Removes duplicate error assertion
catchup/universalFetcher_test.go Fixes incorrect require.Error usage to properly check error type
agreement/pseudonode_test.go Replaces require.ErrorAs with require.ErrorIs for proper error comparison
agreement/fuzzer/networkFacade_test.go Replaces panic(nil) with descriptive panic message
test/linttest/lintissues.go Removes test file for linter validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread util/db/dbutil_test.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@algorandskiy algorandskiy merged commit f381e27 into algorand:master Oct 31, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants