[PR #4300] [CLOSED] fix(oidc): fix failing oidc tests due to uncaught TypeError in to-auth-endpoint.ts #13549

Closed
opened 2026-04-13 08:59:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4300
Author: @ShobhitPatra
Created: 8/29/2025
Status: Closed

Base: canaryHead: fix/oidc


📝 Commits (4)

  • a4801f0 chore: fix failing oidc tests due to uncaught TypeError in to-auth-enpoint.ts
  • 0f30364 Update packages/better-auth/src/api/to-auth-endpoints.ts
  • 35034f5 Update packages/better-auth/src/api/to-auth-endpoints.ts
  • 7b7284f Update to-auth-endpoints.ts

📊 Changes

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

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+3 -3)

📄 Description

Description

I was writing tests for #4263 .
oidc tests were failing with Error : SERVER_ERROR: TypeError: Cannot read properties of undefined (reading 'stack')
at api. (/home/shobhit/Desktop/os/better-auth/packages/better-auth/src/api/to-auth-endpoints.ts:125:60)
at processRequest (file:///home/shobhit/Desktop/os/better-auth/node_modules/better-call/src/router.ts:193:22)
at handler (file:///home/shobhit/Desktop/os/better-auth/node_modules/better-call/src/router.ts:214:16)
at betterFetch (file:///home/shobhit/Desktop/os/better-auth/node_modules/@better-fetch/fetch/src/fetch.ts:77:17)
at Proxy.$fetch (file:///home/shobhit/Desktop/os/better-auth/node_modules/@better-fetch/fetch/src/create-fetch/index.ts:95:10)
at /home/shobhit/Desktop/os/better-auth/packages/better-auth/src/plugins/oidc-provider/oidc.test.ts:312:3
at file:///home/shobhit/Desktop/os/better-auth/node_modules/@vitest/runner/dist/chunk-hooks.js:752:20


Summary by cubic

Fixes an uncaught TypeError in to-auth-endpoints.ts that caused OIDC tests to fail. We now safely inherit error stacks in debug mode without assuming errorWithStack is defined.

  • Bug Fixes
    • Use optional chaining when accessing errorWithStack.stack in endpoint result, before hooks, and after hooks.
    • Prevents SERVER_ERROR TypeError while preserving stack propagation in debug.

🔄 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/4300 **Author:** [@ShobhitPatra](https://github.com/ShobhitPatra) **Created:** 8/29/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/oidc` --- ### 📝 Commits (4) - [`a4801f0`](https://github.com/better-auth/better-auth/commit/a4801f04134f340b8afbc370a813f8e2b5fcf766) chore: fix failing oidc tests due to uncaught TypeError in to-auth-enpoint.ts - [`0f30364`](https://github.com/better-auth/better-auth/commit/0f303641e0869844a158b74906160b0adb48199d) Update packages/better-auth/src/api/to-auth-endpoints.ts - [`35034f5`](https://github.com/better-auth/better-auth/commit/35034f5a961e9ddff097e9c758f5bfcd8bd64336) Update packages/better-auth/src/api/to-auth-endpoints.ts - [`7b7284f`](https://github.com/better-auth/better-auth/commit/7b7284f1133c664dbadea190bed9b5323cfb6a6a) Update to-auth-endpoints.ts ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+3 -3) </details> ### 📄 Description ## Description I was writing tests for #4263 . oidc tests were failing with Error : SERVER_ERROR: TypeError: Cannot read properties of undefined (reading 'stack') at api.<computed> (/home/shobhit/Desktop/os/better-auth/packages/better-auth/src/api/to-auth-endpoints.ts:125:60) at processRequest (file:///home/shobhit/Desktop/os/better-auth/node_modules/better-call/src/router.ts:193:22) at handler (file:///home/shobhit/Desktop/os/better-auth/node_modules/better-call/src/router.ts:214:16) at betterFetch (file:///home/shobhit/Desktop/os/better-auth/node_modules/@better-fetch/fetch/src/fetch.ts:77:17) at Proxy.$fetch (file:///home/shobhit/Desktop/os/better-auth/node_modules/@better-fetch/fetch/src/create-fetch/index.ts:95:10) at /home/shobhit/Desktop/os/better-auth/packages/better-auth/src/plugins/oidc-provider/oidc.test.ts:312:3 at file:///home/shobhit/Desktop/os/better-auth/node_modules/@vitest/runner/dist/chunk-hooks.js:752:20 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes an uncaught TypeError in to-auth-endpoints.ts that caused OIDC tests to fail. We now safely inherit error stacks in debug mode without assuming errorWithStack is defined. - **Bug Fixes** - Use optional chaining when accessing errorWithStack.stack in endpoint result, before hooks, and after hooks. - Prevents SERVER_ERROR TypeError while preserving stack propagation in debug. <!-- 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 08:59:50 -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#13549