[PR #4095] [MERGED] feat: support to infer error types from endpoint #5186

Closed
opened 2026-03-13 12:13:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4095
Author: @himself65
Created: 8/20/2025
Status: Merged
Merged: 8/20/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/08/19/infer-error


📝 Commits (1)

  • 34bbf66 feat: support to infer error types from endpoint

📊 Changes

3 files changed (+34 additions, -5 deletions)

View changed files

📝 packages/better-auth/src/client/client.test.ts (+18 -0)
📝 packages/better-auth/src/client/path-to-object.ts (+10 -5)
📝 packages/better-auth/src/client/test-plugin.ts (+6 -0)

📄 Description

Upstream: https://github.com/Bekacru/better-call/pull/37
Related: https://github.com/better-auth/better-auth/pull/3811


Summary by cubic

Add type-safe error inference for client endpoints. When an endpoint defines an error schema, the client now infers the error type from it instead of using a generic shape.

  • New Features
    • Infer error type from endpoint.options.error when it’s a StandardSchemaV1; otherwise fall back to { code?: string; message?: string }.
    • Added a test for /test to assert the inferred error shape { code: number; message: string; test: boolean }.
    • Test plugin endpoint now provides an error schema using zod v4.

🔄 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/4095 **Author:** [@himself65](https://github.com/himself65) **Created:** 8/20/2025 **Status:** ✅ Merged **Merged:** 8/20/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/08/19/infer-error` --- ### 📝 Commits (1) - [`34bbf66`](https://github.com/better-auth/better-auth/commit/34bbf66a02a68847cc6a2bbf7cc42dce1722ce25) feat: support to infer error types from endpoint ### 📊 Changes **3 files changed** (+34 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/client.test.ts` (+18 -0) 📝 `packages/better-auth/src/client/path-to-object.ts` (+10 -5) 📝 `packages/better-auth/src/client/test-plugin.ts` (+6 -0) </details> ### 📄 Description Upstream: https://github.com/Bekacru/better-call/pull/37 Related: https://github.com/better-auth/better-auth/pull/3811 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add type-safe error inference for client endpoints. When an endpoint defines an error schema, the client now infers the error type from it instead of using a generic shape. - **New Features** - Infer error type from endpoint.options.error when it’s a StandardSchemaV1; otherwise fall back to { code?: string; message?: string }. - Added a test for /test to assert the inferred error shape { code: number; message: string; test: boolean }. - Test plugin endpoint now provides an error schema using zod v4. <!-- 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-03-13 12:13:21 -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#5186