[GH-ISSUE #6938] authClient.$ERROR_CODES` is defined in types but missing at runtime #10677

Closed
opened 2026-04-13 06:57:21 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @sahand12 on GitHub (Dec 22, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6938

Describe the bug
The authClient.$ERROR_CODES property is correctly defined in the TypeScript definitions (index.d.mts) as an object containing error codes. However, at runtime, accessing it returns a Proxy function instead of the actual object.

To Reproduce

const authClient = createAuthClient();
console.log(authClient.$ERROR_CODES);
// Output: Proxy(Function) ...
// Expected: { INVALID_EMAIL: "INVALID_EMAIL", ... }

Cause
It appears $ERROR_CODES is not being passed into the createDynamicPathProxy function in client/react/index.ts. As a result, the proxy trap catches the property access and treats it as a dynamic API route.

System Info

  • better-auth version: 1.4.7
  • Framework: React
Originally created by @sahand12 on GitHub (Dec 22, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6938 **Describe the bug** The `authClient.$ERROR_CODES` property is correctly defined in the TypeScript definitions (`index.d.mts`) as an object containing error codes. However, at runtime, accessing it returns a `Proxy` function instead of the actual object. **To Reproduce** ```ts const authClient = createAuthClient(); console.log(authClient.$ERROR_CODES); // Output: Proxy(Function) ... // Expected: { INVALID_EMAIL: "INVALID_EMAIL", ... } ``` **Cause** It appears `$ERROR_CODES` is not being passed into the `createDynamicPathProxy` function in `client/react/index.ts`. As a result, the proxy trap catches the property access and treats it as a dynamic API route. **System Info** - **better-auth version:** 1.4.7 - **Framework:** React
GiteaMirror added the lockedbug labels 2026-04-13 06:57:22 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 22, 2025):

It looks like you've encountered an issue where authClient.$ERROR_CODES is returning a Proxy instead of the expected object containing error codes. This seems to be related to how the $ERROR_CODES property is handled in the createDynamicPathProxy function, which may be blocking proper access to it.

To troubleshoot this issue, you may want to check the implementation in client/react/index.ts to ensure that $ERROR_CODES is being properly passed into the proxy. This may involve reviewing the related lines of code for any discrepancies or missing assignments.

If you're still having issues after this review, consider checking existing discussions or opening a new issue on GitHub as there could be related bugs or fixes in progress. Also, you could tag team members Beka and Max (@bekacru and @ping__) for more specific support regarding this matter.

Is there a particular part of your code where you suspect this may be happening? Let me know if you need further assistance!

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3684387397 --> @better-auth-agent[bot] commented on GitHub (Dec 22, 2025): It looks like you've encountered an issue where `authClient.$ERROR_CODES` is returning a `Proxy` instead of the expected object containing error codes. This seems to be related to how the `$ERROR_CODES` property is handled in the `createDynamicPathProxy` function, which may be blocking proper access to it. To troubleshoot this issue, you may want to check the implementation in `client/react/index.ts` to ensure that `$ERROR_CODES` is being properly passed into the proxy. This may involve reviewing the related lines of code for any discrepancies or missing assignments. If you're still having issues after this review, consider checking existing discussions or opening a new issue on GitHub as there could be related bugs or fixes in progress. Also, you could tag team members Beka and Max (@bekacru and @ping__) for more specific support regarding this matter. Is there a particular part of your code where you suspect this may be happening? Let me know if you need further assistance! _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@Adityakk9031 commented on GitHub (Dec 23, 2025):

ok

<!-- gh-comment-id:3685191067 --> @Adityakk9031 commented on GitHub (Dec 23, 2025): ok
Author
Owner

@GautamBytes commented on GitHub (Dec 23, 2025):

Looking into it!

<!-- gh-comment-id:3685842335 --> @GautamBytes commented on GitHub (Dec 23, 2025): Looking into it!
Author
Owner

@himself65 commented on GitHub (Dec 23, 2025):

I think right now we haven't guaranteed it's defined in the runtime. But it will be in the next major version

<!-- gh-comment-id:3685849854 --> @himself65 commented on GitHub (Dec 23, 2025): I think right now we haven't guaranteed it's defined in the runtime. But it will be in the next major version
Author
Owner

@sahand12 commented on GitHub (Dec 23, 2025):

The docs explain how to use it, so it’s guaranteed to be defined at runtime. Otherwise, how would the client distinguish between different error types? That said, in the docs it’s only used as a type, not an actual implementation—so technically you’re right. Still, it would be ideal if the runtime behavior and the compile-time type definitions aligned and behaved the same way.

https://www.better-auth.com/docs/concepts/client#error-codes

<!-- gh-comment-id:3688069366 --> @sahand12 commented on GitHub (Dec 23, 2025): The docs explain how to use it, so it’s guaranteed to be defined at runtime. Otherwise, how would the client distinguish between different error types? That said, in the docs it’s only used as a type, not an actual implementation—so technically you’re right. Still, it would be ideal if the runtime behavior and the compile-time type definitions aligned and behaved the same way. https://www.better-auth.com/docs/concepts/client#error-codes
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10677