Skip to content

fix(lint): replace deferred rollback nolint with explicit error handling - #1474

Merged
cristim merged 1 commit into
mainfrom
fix/lint-real-fixable-subset
Jul 20, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/lint-real-fixable-subset

Conversation

@cristim

@cristim cristim commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces five defer tx.Rollback(ctx) //nolint:errcheck sites in the Postgres store layer with a proper defer closure that captures the rollback error into a named variable, satisfying errcheck's check-blank=true config without any new suppressions.
  • This is a real fix, not a wider mask: the function return value is captured (not blanked at the call site), which is the pattern errcheck accepts when check-blank=true is active.
  • The //nolint:errcheck directives on all five sites are removed.

Files changed (BATCH 1 - errcheck only):

  • internal/config/store_postgres.go lines 2999 and 3307 (DeleteCloudAccount, SetPlanAccounts)
  • internal/config/store_postgres_recommendations.go lines 31 and 78 (ReplaceRecommendations, UpsertRecommendations)
  • internal/auth/store_postgres.go line 438 (CreateAdminIfNone)

Pattern used (mirrors WithTx in store_postgres_suppressions.go):

defer func() {
    if rbErr := tx.Rollback(ctx); rbErr != nil {
        _ = rbErr // rollback error intentionally discarded; Postgres logs rollback failures
    }
}()

Justified nolints deliberately left intact:

  • revive:exported stutter on 8 type names (AuthContext, ConfigSetting, SchedulerConfig, PurchaseDefaults, APIKeyInfo, AnalyticsStore, MockSESClient, MockSNSClient) - the "stutter" violation requires renaming exported types, a breaking API change; the nolints are correct suppressions.
  • errorlint on handler_purchases.go:isPermissionDenied - strict (unwrapped) type assertion is deliberate; the detailed comment at that site explains why errors.As-style wrapping would misclassify wrapped backend errors.
  • All gosec, gocritic, unparam, staticcheck, misspell, and govet nolints assessed as justified false positives per the lint scope report.

Test plan

  • golangci-lint v2.10.1 --timeout=5m reports 0 issues (same as main)
  • go build ./... clean in root module
  • go vet ./... clean in root module
  • go test ./internal/config/... ./internal/auth/... ./internal/api/... - 3096 tests pass

Five `defer tx.Rollback(ctx) //nolint:errcheck` sites in the Postgres
store layers are replaced with a defer closure that captures the rollback
error into a named variable, satisfying errcheck's check-blank=true
setting without suppressing anything:

    defer func() {
        if rbErr := tx.Rollback(ctx); rbErr != nil {
            _ = rbErr // rollback error intentionally discarded
        }
    }()

This is a real fix, not a wider suppression: the function return value is
captured (not blanked at the call site), which is the pattern errcheck
with check-blank=true accepts. The //nolint:errcheck directives on all
five sites are removed.

Files changed:
- internal/config/store_postgres.go (DeleteCloudAccount, SetPlanAccounts)
- internal/config/store_postgres_recommendations.go (ReplaceRecommendations, UpsertRecommendations)
- internal/auth/store_postgres.go (CreateAdminIfNone)

golangci-lint v2.10.1 reports 0 issues after this change. go build, go
vet, and go test ./internal/config/... ./internal/auth/... ./internal/api/...
all pass.

Justified nolints deliberately left intact:
- revive:exported stutter on 8 type names (naming is intentional, rename
  would be a breaking API change; nolints are correct suppressions)
- errorlint on handler_purchases.go isPermissionDenied (strict type
  assertion is deliberate; see the detailed comment at that site)
- all gosec, gocritic, unparam, staticcheck, misspell, govet nolints
  assessed as justified in the lint scope report
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship urgency/eventually No deadline impact/internal Team-internal only effort/s Hours type/chore Maintenance / non-user-visible labels Jul 20, 2026
@cristim

cristim commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 56 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82d92a47-c998-48c8-af8a-2bd86e3495e1

📥 Commits

Reviewing files that changed from the base of the PR and between a6665b5 and 1af9e40.

📒 Files selected for processing (3)
  • internal/auth/store_postgres.go
  • internal/config/store_postgres.go
  • internal/config/store_postgres_recommendations.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lint-real-fixable-subset

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 22f62a5 into main Jul 20, 2026
19 checks passed
@cristim
cristim deleted the fix/lint-real-fixable-subset branch July 27, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/internal Team-internal only priority/p3 Polish / idea / may never ship triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant