[PR #4923] [CLOSED] fix: handle symbols in proxy get trap to prevent TypeError #13909

Closed
opened 2026-04-13 09:12:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4923
Author: @zbeyens
Created: 9/26/2025
Status: Closed

Base: canaryHead: fix/segment-replace-error


📝 Commits (1)

  • 88a00fc fix: handle symbols in proxy get trap to prevent TypeError

📊 Changes

1 file changed (+4 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/client/proxy.ts (+4 -1)

📄 Description

Fix TypeError when symbols are accessed on the proxy object. JavaScript/TypeScript Proxies receive both string and symbol properties, especially when:

  • React/Next.js inspects objects for internal symbols ($$typeof, _owner, etc.)
  • Console.log checks for Symbol.toStringTag
  • Debugging tools access various symbols

The fix:

  1. Correctly type the prop parameter as 'string | symbol'
  2. Return undefined for symbol properties early to prevent them from entering the path array

This prevents the "segment.replace is not a function" error that occurs when non-string values attempt string operations.


Summary by cubic

Fixes a crash when symbol properties are read from the dynamic path proxy. The get trap now accepts string | symbol and returns undefined for symbols, preventing non-string keys from entering the path and eliminating the "segment.replace is not a function" error (seen with React/Next.js and console Symbol.toStringTag).


🔄 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/4923 **Author:** [@zbeyens](https://github.com/zbeyens) **Created:** 9/26/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/segment-replace-error` --- ### 📝 Commits (1) - [`88a00fc`](https://github.com/better-auth/better-auth/commit/88a00fcc8266aeebdc4318cbe7c615917e4ddf1a) fix: handle symbols in proxy get trap to prevent TypeError ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/proxy.ts` (+4 -1) </details> ### 📄 Description Fix TypeError when symbols are accessed on the proxy object. JavaScript/TypeScript Proxies receive both string and symbol properties, especially when: - React/Next.js inspects objects for internal symbols ($$typeof, _owner, etc.) - Console.log checks for Symbol.toStringTag - Debugging tools access various symbols The fix: 1. Correctly type the prop parameter as 'string | symbol' 2. Return undefined for symbol properties early to prevent them from entering the path array This prevents the "segment.replace is not a function" error that occurs when non-string values attempt string operations. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a crash when symbol properties are read from the dynamic path proxy. The get trap now accepts string | symbol and returns undefined for symbols, preventing non-string keys from entering the path and eliminating the "segment.replace is not a function" error (seen with React/Next.js and console Symbol.toStringTag). <!-- 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-13 09:12:34 -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#13909