Handle cleanup errors and enable errcheck - #11
Merged
Merged
Conversation
Completes gatekit's entry in the errcheck rollout: 47 findings, 29 in production paths and 18 in tests. Production paths follow the pattern already established in gatehub. A new unexported store/cleanup.go provides closeError, closeWithError and rollbackTransaction, so row, statement, transaction and database cleanup joins onto a named error return instead of being dropped, and a rollback after a successful commit still reports sql.ErrTxDone as the expected outcome rather than a failure. Open now joins its unwind close failures onto the error that caused the unwind. migrateLegacy keeps closing its rows explicitly before BeginTx rather than deferring: reads and writes share the single writer connection, so holding the rows open until return would block the write it is about to make. The proxy has nowhere to return a served connection's close error, so it logs it, treating an already-closed peer as the normal case. sdnotify and the control-plane HTTP client join theirs onto the returned error. In tests, store and database cleanup is asserted, since a failed close means the database did not shut down cleanly and, where a test reopens the file, invalidates everything the reopen asserts. Test-server encode failures are asserted too, because a fixture that fails to encode leaves the test checking a body it never sent. Only net.Pipe and unixgram listener teardown is marked best-effort with _ =. go build, go vet, gofmt, go test and go test -race all pass, and golangci-lint reports zero issues under the repository's own configuration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kt6cL2BR1oWL7v6DtEgCCm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes gatekit's entry in the
ERRCHECK_BACKLOG.mdrollout. 47 findings — 29 in production paths, 18 in tests. Measured with--max-same-issues=0 --max-issues-per-linter=0, so this is the complete backlog, not golangci-lint's first diagnostic page.Production follows the pattern already established in gatehub. A new unexported
store/cleanup.goprovidescloseError,closeWithErrorandrollbackTransaction, so row, statement, transaction and database cleanup joins onto a named error return instead of being dropped. A rollback after a successful commit still reportssql.ErrTxDoneas the expected outcome rather than a failure.Openjoins its unwind close failures onto the error that caused the unwind.Two judgement calls worth review:
migrateLegacykeeps closing its rows explicitly beforeBeginTxrather than deferring. Reads and writes share the single writer connection (db.SetMaxOpenConns(1)), so holding the rows open until return would block the write it's about to make. Deferring here would have been the tidier-looking change and the wrong one.net.ErrClosed) as the normal case, not a fault. This matches sshgate.Tests assert store and database cleanup, since a failed close means the database didn't shut down cleanly and, in the two places a test reopens the file, invalidates everything the reopen then asserts. Test-server encode failures are asserted too: a fixture that fails to encode leaves the test checking a body it never sent. Only
net.Pipeand unixgram listener teardown is marked best-effort with_ =.No public API changes — the named returns don't alter any signature's type.
Verified locally:
go build,go vet,gofmt -l,go test ./...andgo test -race ./...all pass, andgolangci-lintv2.13.2 reports 0 issues under the repository's own config witherrcheckenabled.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kt6cL2BR1oWL7v6DtEgCCm