Skip to content

Commit 9fbdcf4

Browse files
baozhoutaoclaude
andcommitted
chore(changeset): auth ValidationError 4xx mapping (#3398)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 91c0303 commit 9fbdcf4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
"@objectstack/plugin-auth": patch
3+
---
4+
5+
fix(auth): map ObjectQL `ValidationError` to a 4xx on the better-auth paths (#3398)
6+
7+
A field-level validation failure raised by the ObjectQL record-validator
8+
(e.g. an invalid `image` on `POST /api/v1/auth/update-user`) surfaced to the
9+
HTTP client as a **raw 500 with an empty body**. better-auth only maps its own
10+
`APIError`s to structured responses; any other error thrown from an adapter
11+
method propagates to better-call's router as an unhandled fault → `500 {}`.
12+
13+
Added the auth-path analogue of the REST layer's `mapDataError`: the objectql
14+
adapter now detects the ObjectQL validation envelope at its boundary (duck-typed
15+
by `code` / `name`, so plugin-auth keeps no hard dependency on
16+
`@objectstack/objectql` and cross-realm `instanceof` can't bite) and re-throws
17+
it as `APIError('BAD_REQUEST', …)`. `update-user` and friends now answer with a
18+
`400 { code: 'VALIDATION_FAILED', message, fields }` instead of an opaque 500.

0 commit comments

Comments
 (0)