fix(identity): sys_verification.value must not be UNIQUE — breaks OIDC authorize (503)#2333
Conversation
…OIDC authorize
better-auth's oauth-provider stores OIDC authorization codes in the verification
table with `value` = a JSON blob (keyed by user + client + state) that can
legitimately repeat. The UNIQUE index on `value` makes
`/api/v1/auth/oauth2/authorize` fail with `UNIQUE constraint failed:
sys_verification.value` → HTTP 503, which breaks cloud-as-IdP SSO
("Continue with ObjectStack") entirely — the authorize loops forever.
better-auth keys verification lookups on `identifier` (indexed), not `value`,
so a non-unique index on `value` is sufficient.
Found via a local browser E2E of the env→cloud OIDC SSO flow (ADR-0024 D3).
NOTE: existing control-plane DBs already have `uniq_sys_verification_value`;
they need a migration to drop it (schema-sync is additive).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
|
Confirmed required for the env→cloud OIDC SSO chain ("Continue with ObjectStack", ADR-0024 D3): without this, Verified end-to-end (curl + browser) together with the frontend companion objectstack-ai/objectui#2008 — the full flow now JIT-provisions the env Heads-up for existing control-plane DBs: schema-sync is additive and won't drop the existing |
Bug
/api/v1/auth/oauth2/authorize(the cloud-as-IdP OP) returns HTTP 503 with:better-auth's
oauth-providerstores OIDC authorization codes in the verification table withvalue= a JSON blob ({type:"authorization_code", query:{…,state}, userId, sessionId, …}). That blob can legitimately repeat (same user+client+state on retry), butsys-verification.object.tsdeclared{ fields: ['value'], unique: true }→ the insert violates the constraint → 503.Impact: the env→cloud OIDC SSO ("Continue with ObjectStack", ADR-0024 D3) loops forever — the cloud login SPA re-issues the signed authorize request every ~20s and never completes.
Fix
value→unique: false(keep the index for lookups; better-auth keys onidentifier, notvalue).Found via
Local browser E2E of the env-side SSO against a real cloud OP (anonymous env login → "Continue with ObjectStack"). Confirmed in the server log (
SqliteError … SQLITE_CONSTRAINT_UNIQUE); droppinguniq_sys_verification_valuein the live DB stopped the UNIQUE errors.Follow-ups (separate)
uniq_sys_verification_value; schema-sync is additive, so they need a one-offDROP INDEX.🤖 Generated with Claude Code