[PR #6794] [MERGED] fix(anonymous): missing path breaks anonymous hooks #15135

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6794
Author: @ping-maxwell
Created: 12/16/2025
Status: Merged
Merged: 12/24/2025
Merged by: @himself65

Base: canaryHead: fix/missing-path-for-anonymous


📝 Commits (8)

  • 5e8bc12 fix(anonymous): missing path breaks anonymous hooks
  • 8152613 Merge branch 'canary' into fix/missing-path-for-anonymous
  • cd55861 Merge branch 'canary' into fix/missing-path-for-anonymous
  • afd7d0d update: add debug info on fail
  • 2f90788 Merge branch 'canary' into fix/missing-path-for-anonymous
  • be8587e fix: handler
  • aeb09df fix: handler
  • d2f5017 fix: wording

📊 Changes

3 files changed (+45 additions, -27 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+34 -17)
📝 packages/better-auth/src/plugins/anonymous/index.ts (+10 -9)
📝 packages/core/src/types/plugin.ts (+1 -1)

📄 Description

Recently, we supported createAuthEndpoint to not require a path, however we forgot to update a specific type which caused the anonmous plugin to have breaking code.

Any users who use the anonymous plugin and accessed an endpoint with not path (such as auth.api.setPassword) would run into an error.


Summary by cubic

Fixes anonymous plugin errors when an endpoint has no path. Anonymous hooks now work with pathless endpoints like auth.api.setPassword, and hook matcher failures are handled safely.

  • Bug Fixes
    • Made HookEndpointContext.path optional to match createAuthEndpoint.
    • Guarded matcher checks with ctx.path?.startsWith(...) and a final || false to avoid runtime errors.
    • Wrapped hook matcher in try/catch, log with hook source, and return a generic API error to avoid leaking internal details.

Written for commit d2f5017521. 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/6794 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 12/16/2025 **Status:** ✅ Merged **Merged:** 12/24/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/missing-path-for-anonymous` --- ### 📝 Commits (8) - [`5e8bc12`](https://github.com/better-auth/better-auth/commit/5e8bc12006fde73a533f164900d28b4896eb6449) fix(anonymous): missing path breaks anonymous hooks - [`8152613`](https://github.com/better-auth/better-auth/commit/8152613c4f7e7bcaa54473e1466ea43fd013c05b) Merge branch 'canary' into fix/missing-path-for-anonymous - [`cd55861`](https://github.com/better-auth/better-auth/commit/cd5586166949f2abddce17781e35fd53d26a41e2) Merge branch 'canary' into fix/missing-path-for-anonymous - [`afd7d0d`](https://github.com/better-auth/better-auth/commit/afd7d0d07ac7feaeab0f9fb1be5b025d444d9635) update: add debug info on fail - [`2f90788`](https://github.com/better-auth/better-auth/commit/2f9078801e6fc662c349f58adb1839b72f954078) Merge branch 'canary' into fix/missing-path-for-anonymous - [`be8587e`](https://github.com/better-auth/better-auth/commit/be8587e5edc362639baedb696f8eba4326382be1) fix: handler - [`aeb09df`](https://github.com/better-auth/better-auth/commit/aeb09dff21a93ee926c0a002b7286722c99e30f6) fix: handler - [`d2f5017`](https://github.com/better-auth/better-auth/commit/d2f5017521c6a78acdfcd9488b82a5afef15eed6) fix: wording ### 📊 Changes **3 files changed** (+45 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+34 -17) 📝 `packages/better-auth/src/plugins/anonymous/index.ts` (+10 -9) 📝 `packages/core/src/types/plugin.ts` (+1 -1) </details> ### 📄 Description Recently, we supported `createAuthEndpoint` to not require a `path`, however we forgot to update a specific type which caused the anonmous plugin to have breaking code. Any users who use the anonymous plugin and accessed an endpoint with not path (such as `auth.api.setPassword`) would run into an error. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes anonymous plugin errors when an endpoint has no path. Anonymous hooks now work with pathless endpoints like auth.api.setPassword, and hook matcher failures are handled safely. - **Bug Fixes** - Made HookEndpointContext.path optional to match createAuthEndpoint. - Guarded matcher checks with ctx.path?.startsWith(...) and a final || false to avoid runtime errors. - Wrapped hook matcher in try/catch, log with hook source, and return a generic API error to avoid leaking internal details. <sup>Written for commit d2f5017521c6a78acdfcd9488b82a5afef15eed6. 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-13 09:50:57 -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#15135