Skip to content

fix(platform-objects): drop unenforceable sys_user email_unique validation (#1485 regression) - #1490

Merged
xuyushun441-sys merged 1 commit into
mainfrom
fix/adr-1485-validation-type-regression
Jun 1, 2026
Merged

fix(platform-objects): drop unenforceable sys_user email_unique validation (#1485 regression)#1490
xuyushun441-sys merged 1 commit into
mainfrom
fix/adr-1485-validation-type-regression

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

What & why

main has been red since #1485 ("enforce all declared validation-rule types; trim the unenforceable three"). That PR removed unique / async / custom from the ValidationRuleSchema discriminated union, but sys_user still declared:

validations: [{name: 'email_unique',type: 'unique', ... }]

So ObjectSchema.create(SysUser) throws at module load:

ZodError: Invalid discriminator value at validations[0].type.
Expected 'script' | 'state_machine' | 'format' | 'cross_field' | 'json_schema' | 'conditional'

…which fails packages/platform-objects/src/platform-objects.test.ts (CI "Test Core"). CI history: 11905faf8 (#1484) green → 764824299 (#1485) red → still red through f950b43d9 (#1487).

Fix

The validation rule was redundant: sys_user already declares a unique index on email (indexes: [{ fields: ['email'], unique: true }]), and the table is managedBy: 'better-auth' which enforces email uniqueness at the source. unique was trimmed precisely because it's unenforceable as a synchronous validation rule. So the rule is removed (not migrated). Swept the repo — no other object uses a trimmed validation type.

Verification

platform-objects.test.ts52/52 pass locally with the fix (was a failing suite before).

Unblocks #1488 (notification dispatcher test) which is red only due to this pre-existing failure.

🤖 Generated with Claude Code

…ation (#1485 regression)
#1485 trimmed the `unique`/`async`/`custom` validation-rule types from the
union, but sys_user still declared `email_unique` with type: 'unique', so
ObjectSchema.create threw a ZodError at load and platform-objects.test.ts (and
main CI) went red. The rule was redundant — sys_user already has a unique index
on email and better-auth enforces it on the managed user table — so it's
removed rather than migrated. No other object uses a trimmed type.
Verified: platform-objects.test.ts 52/52 pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specBuildingBuildingPreview, CommentJun 1, 2026 8:50pm

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tooling size/s labels Jun 1, 2026
@xuyushun441-sys
xuyushun441-sys merged commit 7ae6abc into mainJun 1, 2026
9 of 11 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/stooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xuyushun441-sys@os-zhuang