[PR #7792] [MERGED] fix(db): skip 'adapter.delete' in deleteWithHooks when entity not found #33157

Closed
opened 2026-04-17 23:49:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7792
Author: @bytaesu
Created: 2/4/2026
Status: Merged
Merged: 2/4/2026
Merged by: @himself65

Base: canaryHead: 2026-02-04/fix/delete-with-hooks-missing-entity


📝 Commits (1)

  • 0bcd7d5 fix(db): skip 'adapter.delete' in deleteWithHooks when entity not found

📊 Changes

2 files changed (+30 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/db/internal-adapter.test.ts (+27 -0)
📝 packages/better-auth/src/db/with-hooks.ts (+3 -1)

📄 Description

Note

https://www.prisma.io/docs/orm/reference/error-reference#p2025


Summary by cubic

Skip adapter.delete in deleteWithHooks when the entity is missing to prevent Prisma P2025 errors. Adds a test to ensure deletion is not attempted for missing verification records.

  • Bug Fixes
    • Only run adapter.delete when a target entity exists (via entityToDelete) and when customDeleteFn allows it.
    • Added test that deletes a verification record first, then verifies adapter.delete is not called.

Written for commit 0bcd7d5fb5. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7792 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/4/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-04/fix/delete-with-hooks-missing-entity` --- ### 📝 Commits (1) - [`0bcd7d5`](https://github.com/better-auth/better-auth/commit/0bcd7d5fb5f20864653e8f6986c4d83c1fa415dd) fix(db): skip 'adapter.delete' in deleteWithHooks when entity not found ### 📊 Changes **2 files changed** (+30 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.test.ts` (+27 -0) 📝 `packages/better-auth/src/db/with-hooks.ts` (+3 -1) </details> ### 📄 Description > [!NOTE] > https://www.prisma.io/docs/orm/reference/error-reference#p2025 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Skip adapter.delete in deleteWithHooks when the entity is missing to prevent Prisma P2025 errors. Adds a test to ensure deletion is not attempted for missing verification records. - **Bug Fixes** - Only run adapter.delete when a target entity exists (via entityToDelete) and when customDeleteFn allows it. - Added test that deletes a verification record first, then verifies adapter.delete is not called. <sup>Written for commit 0bcd7d5fb5f20864653e8f6986c4d83c1fa415dd. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:49:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#33157