Skip to content

Commit feaa190

Browse files
committed
fix(auth): satisfy errcheck and shadow lints in bootstrap tx scaffolding
The bootstrap-race fix introduced two new golangci-lint failures on the new transaction scaffolding in CreateAdminIfNone (Lint Code is failing on this PR for these reasons): - `_ = tx.Rollback(ctx)` does not satisfy errcheck under this project's `check-blank: true` setting. Replace with the project-standard `defer tx.Rollback(ctx) //nolint:errcheck` pattern used in internal/config/store_postgres.go. - `if _, err := tx.Exec(...)` on the advisory-lock acquire shadowed the outer `err` (govet shadow). Drop the short-declaration so the lock-exec assigns to the outer variable. No behavior change on the success or known-error paths. go test ./internal/auth/ -race: 577 passed. golangci-lint on store_postgres.go: no new findings on the touched lines.
1 parent 143babc commit feaa190

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎internal/auth/store_postgres.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,13 @@ func (s *PostgresStore) CreateAdminIfNone(ctx context.Context, user *User) (bool
433433
return false, fmt.Errorf("failed to begin admin bootstrap transaction: %w", err)
434434
}
435435
// Rollback is a no-op after a successful Commit; on any earlier return
436-
// it also releases the advisory lock.
437-
defer func() { _ = tx.Rollback(ctx) }()
436+
// it also releases the advisory lock. Matches the project convention
437+
// (e.g. internal/config/store_postgres.go) for deferred rollback.
438+
defer tx.Rollback(ctx) //nolint:errcheck
438439

439440
// Serialize against concurrent bootstrap calls and against the
440441
// min-one-admin deferred trigger (see adminInvariantAdvisoryLockKey).
441-
if _, err := tx.Exec(ctx, "SELECT pg_advisory_xact_lock($1)", adminInvariantAdvisoryLockKey); err != nil {
442+
if _, err = tx.Exec(ctx, "SELECT pg_advisory_xact_lock($1)", adminInvariantAdvisoryLockKey); err != nil {
442443
return false, fmt.Errorf("failed to acquire admin bootstrap lock: %w", err)
443444
}
444445

0 commit comments

Comments
 (0)