Username plugin is using errors from Two factor plugin #819

Closed
opened 2026-03-13 08:05:38 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @TheYoxy on GitHub (Mar 10, 2025).

Hi,

While looking to use the error codes from Username plugin, I tried to use the errors codes as described here.
When looking, I've seen that the errors used in the username plugin are not the one described inside the plugin and then cannot be referenced by using $ERROR_CODES from the auth instance.

The errors used inside the plugin:
https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L40-L48

The errors that are returned from the plugin and inferred for $ERROR_CODES
https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L9
https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L304

Is that the expected behavior or should the errors described in the plugin ?
(I can open a PR to fix it if needed.)

Originally created by @TheYoxy on GitHub (Mar 10, 2025). Hi, While looking to use the error codes from Username plugin, I tried to use the errors codes as described [here](https://better-auth.vercel.app/docs/concepts/client#error-codes). When looking, I've seen that the errors used in the username plugin are not the one described inside the plugin and then cannot be referenced by using `$ERROR_CODES` from the `auth` instance. > The errors used inside the plugin: > https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L40-L48 > The errors that are returned from the plugin and inferred for `$ERROR_CODES` > https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L9 > https://github.com/better-auth/better-auth/blob/f90581d7ab0493fb58d3c2654c326f6f28a684b3/packages/better-auth/src/plugins/username/index.ts#L304 Is that the expected behavior or should the errors described in the plugin ? (I can open a PR to fix it if needed.)
Author
Owner

@Lukem121 commented on GitHub (Mar 11, 2025):

bump

@Lukem121 commented on GitHub (Mar 11, 2025): bump
Author
Owner

@Bekacru commented on GitHub (Apr 12, 2025):

fixed

@Bekacru commented on GitHub (Apr 12, 2025): fixed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#819