[PR #4907] [MERGED] chore: type check on error code uppercase #5650

Closed
opened 2026-03-13 12:30:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4907
Author: @dvanmali
Created: 9/25/2025
Status: Merged
Merged: 9/25/2025
Merged by: @himself65

Base: canaryHead: errorCodes


📝 Commits (3)

  • 5ac0757 fix: USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL as const
  • 8552948 style: lint
  • 7da67bd feat: type checking

📊 Changes

9 files changed (+83 additions, -17 deletions)

View changed files

📝 packages/better-auth/src/api/routes/sign-up.ts (+1 -1)
📝 packages/better-auth/src/api/routes/update-user.ts (+1 -1)
📝 packages/better-auth/src/error/codes.ts (+7 -3)
📝 packages/better-auth/src/plugins/admin/admin.ts (+1 -1)
📝 packages/better-auth/src/plugins/admin/error-codes.ts (+8 -3)
📝 packages/better-auth/src/plugins/captcha/error-codes.ts (+6 -4)
📝 packages/better-auth/src/plugins/organization/error-codes.ts (+4 -2)
📝 packages/better-auth/src/plugins/username/error-codes.ts (+4 -2)
packages/better-auth/src/utils/error-codes.ts (+51 -0)

📄 Description

Error constants and message should match. Constant is all capital format of message.

Closes: #4386


Summary by cubic

Standardized error code constants to match their messages and split the "user already exists" case into two clear codes. This fixes mismatched error responses and clarifies when a user must use another email.

  • Bug Fixes
    • Added USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL; kept USER_ALREADY_EXISTS as "User already exists."
    • Updated sign-up, change-email, and admin create-user flows to use the new constant.
    • Documented the uppercase constant naming rule in error code files.

🔄 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/4907 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 9/25/2025 **Status:** ✅ Merged **Merged:** 9/25/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `errorCodes` --- ### 📝 Commits (3) - [`5ac0757`](https://github.com/better-auth/better-auth/commit/5ac075709ba56e591c22b1648abf30bf43fddcf2) fix: USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL as const - [`8552948`](https://github.com/better-auth/better-auth/commit/855294820c7ea4787e84da67931cd98f46854c17) style: lint - [`7da67bd`](https://github.com/better-auth/better-auth/commit/7da67bd55266ff2902062724dd0438100584af42) feat: type checking ### 📊 Changes **9 files changed** (+83 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+1 -1) 📝 `packages/better-auth/src/error/codes.ts` (+7 -3) 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/admin/error-codes.ts` (+8 -3) 📝 `packages/better-auth/src/plugins/captcha/error-codes.ts` (+6 -4) 📝 `packages/better-auth/src/plugins/organization/error-codes.ts` (+4 -2) 📝 `packages/better-auth/src/plugins/username/error-codes.ts` (+4 -2) ➕ `packages/better-auth/src/utils/error-codes.ts` (+51 -0) </details> ### 📄 Description Error constants and message should match. Constant is all capital format of message. Closes: #4386 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Standardized error code constants to match their messages and split the "user already exists" case into two clear codes. This fixes mismatched error responses and clarifies when a user must use another email. - **Bug Fixes** - Added USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL; kept USER_ALREADY_EXISTS as "User already exists." - Updated sign-up, change-email, and admin create-user flows to use the new constant. - Documented the uppercase constant naming rule in error code files. <!-- 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-03-13 12:30:28 -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#5650