Repository navigation
fix(auth): seeds run validateUserInfo and database hooks in a hermetic seed context (#1058) - #1059
Merged
Merged
Conversation
…c seed context (#1058) Seeding called Better Auth's internalAdapter outside any endpoint context, so a configured user.validateUserInfo refused every seed with "User validation requires an endpoint context", and databaseHooks got no context. Seeding now runs inside runWithEndpointContext with a synthetic context (no request, empty headers). A validator rejection or a create.before hook returning false refuses the run naming the user and the hook. Also removes stale merge markers from the auth CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 30, 2026 15:39
…egenerate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1058
Reproduction
A hermetic run with
betterAuth.user.validateUserInfoconfigured and atests/seed.jsonauth user failed to activate:Extension "auth" failed to activate: User validation requires an endpoint context(APIError 403validation_context_missing). Better Auth 1.7.6'sinternalAdapter.createUserrequires an endpoint context whenevervalidateUserInfois set, and seeding had none.databaseHooksran withctxundefined.Fix
seedUsersruns inside Better Auth'srunWithEndpointContextwith a hermetic seed context: the auth context, no request (request,pathundefined), emptyheaders.validateUserInfogets{method: 'email-password', action: 'create-user'}.auth: seeded user <id> was refused by betterAuth.user.validateUserInfo (<code>...). Auser.create.before/account.create.beforehook returningfalserefuses naming the hook (previously it produced a misleading "generates its own ids" error).@better-auth/core1.7.6 (same version asbetter-auth, already installed transitively) as a direct dependency forrunWithEndpointContext; better-auth does not re-export it.packages/auth/CHANGELOG.mdon main.Evidence
packages/auth/test/owner-database.test.ts: failed before the fix with the error above; passes after. It asserts the validator's source and context, hook order (user.before,user.after,account.after) and context, sign-in of the seeded user, and both refusal messages.npm run verifygreen locally.Limitation: covered with Better Auth's memory adapter; the bundled SQLite path shares the same
seedUserscode.🤖 Generated with Claude Code