[PR #6317] [MERGED] fix: improve InferErrorCodes type safety with property check #23489

Closed
opened 2026-04-15 21:45:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6317
Author: @bytaesu
Created: 11/25/2025
Status: Merged
Merged: 11/25/2025
Merged by: @himself65

Base: canaryHead: 2025-11-26/fix/infer-client-error-codes


📝 Commits (2)

  • 9c73c8f fix: improve InferErrorCodes type safety with property check
  • bff95bd test: add test case for infer multiple plugins error code

📊 Changes

2 files changed (+71 additions, -5 deletions)

View changed files

📝 packages/better-auth/src/client/client.test.ts (+67 -2)
📝 packages/better-auth/src/client/types.ts (+4 -3)

📄 Description

This PR improves the type safety of InferErrorCodes. In the previous code, the absence of $ERROR_CODES could cause unexpected behavior. For example, in the current demo app’s auth-client, all plugin error codes are lost.


Summary by cubic

Fixes type inference for client error codes so plugins without $ERROR_CODES no longer wipe out codes from other plugins. Error codes are now reliably inferred when multiple plugins are used.

  • Bug Fixes
    • Updated InferErrorCodes to guard on $InferServerPlugin.$ERROR_CODES and only merge valid Record<string, string>.
    • Added a test that composes multiple plugins and asserts expected error codes are present.

Written for commit bff95bddbe. Summary will update automatically 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/6317 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 11/25/2025 **Status:** ✅ Merged **Merged:** 11/25/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-11-26/fix/infer-client-error-codes` --- ### 📝 Commits (2) - [`9c73c8f`](https://github.com/better-auth/better-auth/commit/9c73c8f818f27cf6960ff4aa5e7868507a1d9911) fix: improve InferErrorCodes type safety with property check - [`bff95bd`](https://github.com/better-auth/better-auth/commit/bff95bddbe8a02c3e07da68061db2d3b83f09af5) test: add test case for infer multiple plugins error code ### 📊 Changes **2 files changed** (+71 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/client.test.ts` (+67 -2) 📝 `packages/better-auth/src/client/types.ts` (+4 -3) </details> ### 📄 Description This PR improves the type safety of InferErrorCodes. In the previous code, the absence of $ERROR_CODES could cause unexpected behavior. For example, in the current demo app’s auth-client, all plugin error codes are lost. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes type inference for client error codes so plugins without $ERROR_CODES no longer wipe out codes from other plugins. Error codes are now reliably inferred when multiple plugins are used. - **Bug Fixes** - Updated InferErrorCodes to guard on $InferServerPlugin.$ERROR_CODES and only merge valid Record<string, string>. - Added a test that composes multiple plugins and asserts expected error codes are present. <sup>Written for commit bff95bddbe8a02c3e07da68061db2d3b83f09af5. Summary will update automatically 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-15 21:45:30 -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#23489