[VW-364] Upgrade better-auth to 1.6.23 to clear critical audit advisory#153
[VW-364] Upgrade better-auth to 1.6.23 to clear critical audit advisory#153markglose-bc wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
📝 WalkthroughWalkthroughThis PR upgrades better-auth to 1.6.23 and adds the ChangesBetter-auth v1.6.x api-key migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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)
prisma/migrations/20260709120000_apikey_reference_id/migration.sql (1)
15-15: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsider
CREATE INDEX CONCURRENTLYfor production deployments.The standard
CREATE INDEXblocks writes for the duration of index creation. If theapikeytable is large in production, useCONCURRENTLYto avoid write blocking. Since Prisma wraps migrations in a transaction by default, you'll need to add the-- -- prisma-migrate-disable-transactiondirective at the top of the file.♻️ Proposed refactor for concurrent index creation
+-- -- prisma-migrate-disable-transaction -- better-auth's `@better-auth/api-key` 1.6.x plugin renames the owner column -- `userId` -> `referenceId` and adds a required `configId`. Rename (not -- drop/add) so existing keys are preserved. -- RenameColumn ALTER TABLE "apikey" RENAME COLUMN "userId" TO "referenceId"; -- RenameForeignKey ALTER TABLE "apikey" RENAME CONSTRAINT "apikey_userId_fkey" TO "apikey_referenceId_fkey"; -- AddColumn ALTER TABLE "apikey" ADD COLUMN "configId" TEXT NOT NULL DEFAULT 'default'; -- CreateIndex -CREATE INDEX "apikey_referenceId_idx" ON "apikey"("referenceId"); +CREATE INDEX CONCURRENTLY "apikey_referenceId_idx" ON "apikey"("referenceId");Note:
CONCURRENTLYcannot run inside a transaction, so the directive is required. Also, if a previousapikey_userId_idxexists, addDROP INDEX "apikey_userId_idx";before creating the new index.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@prisma/migrations/20260709120000_apikey_reference_id/migration.sql` at line 15, The index creation for the apikey referenceId migration should be made non-blocking for production by switching the existing `CREATE INDEX` in the migration to a concurrent index build. Update the migration file to include the Prisma transaction-disabling directive, use `CREATE INDEX CONCURRENTLY` for `apikey_referenceId_idx`, and if the old `apikey_userId_idx` still exists, drop it before creating the new index so the migration can run safely outside a transaction.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@prisma/migrations/20260709120000_apikey_reference_id/migration.sql`:
- Line 15: The index creation for the apikey referenceId migration should be
made non-blocking for production by switching the existing `CREATE INDEX` in the
migration to a concurrent index build. Update the migration file to include the
Prisma transaction-disabling directive, use `CREATE INDEX CONCURRENTLY` for
`apikey_referenceId_idx`, and if the old `apikey_userId_idx` still exists, drop
it before creating the new index so the migration can run safely outside a
transaction.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ab143c92-1e13-43f7-b27e-53eabbc066a7
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (8)
package.jsonprisma/migrations/20260709120000_apikey_reference_id/migration.sqlprisma/schema.prismascripts/create-test-api-key.tssrc/features/user/server/routers.tssrc/lib/auth-client.tssrc/lib/auth.tssrc/trpc/init.ts
better-authadvisory was resolved in1.6.11upgrading from
1.4.9to1.6.23had breaking changes, so I split it out into this PRmainly
Extracted the API-key plugin into a separate package →
@better-auth/api-keyRenamed the key's owner column
userId → referenceIdand added a requiredconfigIdSummary by CodeRabbit
New Features
Bug Fixes
Chores