[PR #6488] [MERGED] fix(db): correctly unwrap validator result in schema parsing #23600

Closed
opened 2026-04-15 21:51:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6488
Author: @GautamBytes
Created: 12/3/2025
Status: Merged
Merged: 12/3/2025
Merged by: @himself65

Base: canaryHead: fix/validator-unwrapping


📝 Commits (1)

  • 73a1535 fix(db): unwrap validator result to store raw value

📊 Changes

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

View changed files

📝 packages/better-auth/src/db/schema.ts (+12 -1)

📄 Description

Fixes a regression introduced in v1.4.0 where fields using additionalFields with a validator (zod/standard schema) were being saved as a JSON object containing the validator metadata ({ value: "..." }) rather than the raw value.

Changes:

  • Modified packages/better-auth/src/db/schema.ts inside parseInputData.
  • Added logic to handle the Standard Schema validation result:
  • Now explicitly checks result.issues and throws a BAD_REQUEST error if validation fails.
  • Assigns result.value to the parsed data object instead of the full result object.

Fixes Fixes #6482


Summary by cubic

Fixes a v1.4.0 regression where additionalFields using a validator were saved with validator metadata instead of the raw value. Adds clear validation errors and blocks unsupported async validators.

  • Bug Fixes
    • Unwrap Standard Schema validation result in parseInputData and store result.value.
    • Throw BAD_REQUEST with the first issue message when validation fails.
    • Throw INTERNAL_SERVER_ERROR if the validator returns a Promise (async not supported).

Written for commit 73a1535f34. 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/6488 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 12/3/2025 **Status:** ✅ Merged **Merged:** 12/3/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/validator-unwrapping` --- ### 📝 Commits (1) - [`73a1535`](https://github.com/better-auth/better-auth/commit/73a1535f34dd489e1326f515812b4501b4319dfd) fix(db): unwrap validator result to store raw value ### 📊 Changes **1 file changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/schema.ts` (+12 -1) </details> ### 📄 Description Fixes a regression introduced in v1.4.0 where fields using additionalFields with a validator (zod/standard schema) were being saved as a JSON object containing the validator metadata ({ value: "..." }) rather than the raw value. **Changes**: - Modified packages/better-auth/src/db/schema.ts inside parseInputData. - Added logic to handle the Standard Schema validation result: - Now explicitly checks result.issues and throws a BAD_REQUEST error if validation fails. - Assigns result.value to the parsed data object instead of the full result object. Fixes Fixes #6482 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a v1.4.0 regression where additionalFields using a validator were saved with validator metadata instead of the raw value. Adds clear validation errors and blocks unsupported async validators. - **Bug Fixes** - Unwrap Standard Schema validation result in parseInputData and store result.value. - Throw BAD_REQUEST with the first issue message when validation fails. - Throw INTERNAL_SERVER_ERROR if the validator returns a Promise (async not supported). <sup>Written for commit 73a1535f34dd489e1326f515812b4501b4319dfd. 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-15 21:51:31 -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#23600