Skip to content

Conversation

@justin-layerv
Copy link
Contributor

@justin-layerv justin-layerv commented Jan 4, 2026

Summary

  • Enable the errcheck linter in golangci-lint configuration
  • Fix all 74 unchecked error issues across the codebase

Changes

Configuration

  • .golangci.yml: Move errcheck from disable to enable list, remove test file exclusion for errcheck

nhp module (24 issues fixed)

core/scheme/curve/curve.go:

  • Check SetPrivateKey error return

core/ztdo/noise.go:

  • Explicitly ignore rand.Read return (crypto/rand never fails)

core/ztdo/ztdo.go:

  • Handle file write errors in Encrypt and Decrypt
  • Check SetMetadata and SetCipherText returns
  • Explicitly ignore marshal error in toBuffer

log/logger.go:

  • Explicitly ignore Output errors (logging failures are non-critical)
  • Explicitly ignore file.Sync error

utils/file.go:

  • Check watcher.Add error

endpoints module (50 issues fixed)

ac/:

  • Handle config update function errors in watch callbacks
  • Handle httpServer.Shutdown, ipset.Add, SendPacket errors
  • Wrap HandleUdpACOperations goroutine call to handle error

agent/:

  • Handle config update function errors in watch callbacks
  • Handle preAccessRequest, processPreAccessAction errors
  • Handle SendPacket, SaveStructAsJsonFile, ExitKnockRequest errors

db/:

  • Handle config update function errors in watch callbacks
  • Handle SetMetadata, SetNhpServer, dataPrkStore.Save errors
  • Handle SendPacket, fromJson, file.Write errors
  • Wrap HandleUdpDataKeyWrappingOperations goroutine call to handle error

server/:

  • Handle config update function errors in watch callbacks
  • Handle all updateXxx function errors in etcd config update

Test plan

  • golangci-lint run ./... passes on both modules with 0 issues
  • All GitHub Actions checks pass

Closes #1372

🤖 Generated with Claude Code

windcbf
windcbf previously approved these changes Jan 5, 2026
justin-layerv and others added 3 commits January 4, 2026 21:49
Enable the errcheck linter in golangci-lint configuration and fix all
74 unchecked error issues across the codebase:

nhp module (24 issues fixed):
- core/scheme/curve/curve.go: check SetPrivateKey error
- core/ztdo/noise.go: explicitly ignore rand.Read return
- core/ztdo/ztdo.go: handle file write and encryption errors
- log/logger.go: explicitly ignore logger Output errors
- utils/file.go: check watcher.Add error

endpoints module (50 issues fixed):
- ac/: handle config update and SendPacket errors
- agent/: handle config update, preAccess and knock errors
- db/: handle config update and data key store errors
- server/: handle config update and etcd watch errors

Closes #1372

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Critical: Properly handle dataPrkStore.Save() error to prevent data loss
- Fix preAccessRequest() to log warning instead of silently ignoring
- Fix SaveStructAsJsonFile() to return HTTP error on failure
- Fix multi-return value functions (SendPacket, ipset.Add) using _, _
- Fix server module errcheck issues not caught in initial PR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Goroutines that capture loop variables by reference can process wrong
data if the variable is reassigned before the goroutine executes.

Fix by passing the loop variable as a parameter to the closure,
ensuring each goroutine receives its own copy of the value.

Affected files:
- endpoints/server/udpserver.go (8 goroutines)
- endpoints/ac/udpac.go (1 goroutine)
- endpoints/db/udpdevice.go (1 goroutine)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@windcbf windcbf merged commit 72c7e9a into main Jan 7, 2026
10 checks passed
@windcbf windcbf deleted the fix/enable-errcheck branch January 7, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable errcheck linter after fixing existing issues

3 participants