chore(deps): migrate postgres driver from pgx v4 to v5 - #1817
Conversation
Swaps pgx/v4 and the standalone pgconn module for pgx/v5, which absorbed them. Repository code is unchanged; error matching now uses the v5 pgconn error type. Adds tests for the postgres error translation and the billing transaction replay path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/store/postgres/billing_transactions_repository_test.go (1)
94-110: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert translated diagnostic details too.
The table cases populate only
Codeand assertErrorIs. A regression that dropsPgError.DetailorPgError.Messagefrom the translated error would still pass. Add representative detail/message values and assert they are preserved.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f0af9ba-4f56-4bb4-88dd-e58a9021c47e
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (7)
cmd/serve.gogo.modinternal/store/postgres/billing_transactions_repository.gointernal/store/postgres/billing_transactions_repository_pg_test.gointernal/store/postgres/billing_transactions_repository_test.gointernal/store/postgres/postgres.gotest/e2e/testbench/postgres.go
Summary
Migrates the Postgres driver from pgx v4 to pgx v5. The v4 line is in maintenance mode; v5 absorbed the standalone pgconn, pgproto3 and pgtype modules. Resolves the two govulncheck findings that have no fix on the v4 line (GO-2026-5004, GO-2026-4518). GO-2026-5617 is no longer reported as reachable once the v4 module family leaves the dependency graph.
Changes
github.com/jackc/pgx/v4→github.com/jackc/pgx/v5: driver registration (stdlib) in cmd/serve.go and internal/store/postgres,pgx.ParseConfigin cmd/serve.go,pgx.Connectreadiness probe in test/e2e/testbenchgithub.com/jackc/pgconn→github.com/jackc/pgx/v5/pgconnfor Postgres error inspection (postgres.go, billing_transactions_repository.go)TestCheckPostgresErrorcovering every error-code translation incheckPostgresError, including wrapped errors and passthrough casesTestBillingTransactionRepositorycoveringCreateEntryand replaying the same transaction (ErrAlreadyApplied)Technical Details
No query or repository logic changes — the store layer talks to database/sql via goqu/sqlx, and the registered driver name stays
pgx, so configuration is unchanged. Error matching relies on the driver returning v5's*pgconn.PgError; the new repository test exercises this against a real Postgres, including the constraint-name check in the billing replay path.Base is
chore/upgrade-go-deps(#1813); this PR retargets to main automatically when that merges.Test Plan
go build ./...andgo vet ./...passmake lintpasses (0 issues)make testpasses (race detector, -count 2)make e2e-testpasses against live Postgres + SpiceDB containersgovulncheck ./...reports no findings from pgx modulesSQL Safety (if your PR touches
*_repository.goorgoqu.*)?placeholders,goqu.Ex{}, orgoqu.Record{}— neverfmt.Sprintfor+building a query that gets executed.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L(usemake_interval(hours => ?)-style functions instead).//nolint:forbidigoor// #nosec G20xannotation has a one-line justification on the same line that a reviewer can verify.🤖 Generated with Claude Code