Repository navigation
fix(auth): a cloud-managed runtime's password refusal is shown in the session's language - #37965
Conversation
toAuthError reads code, message, details and userMessage from the ADR-0112 envelope when better-auth's flat body has none, and forgotPassword, resetPassword and setInitialPassword now go through it. The sign-in refusal map and a new password-door map turn 409 RESOURCE_CONFLICT into a localized sentence that points at the identity provider's button. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…sword Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Contract reviewServed-tier: First record on this head. Inputs: card #34171, claim 7217934544, claim revision 7218058235, dev reports 7218033222 and 7219295017, the PR body, The committed tree touches no published schema ( ① Derived judgments
② Semver level
③ Boundary flags
FindingsS1 (should-fix): the declaration should read
S2 (should-fix): the changeset's last paragraph, "Self-hosted deployments never answer this refusal on these doors, so nothing changes there", is not true for the reset and set-password doors.
N1 (nit): a refusal whose message is the empty string now reaches the page as an empty description on N2 (nit, a card): the profile page's password card ( N3 (nit): the PR body says plugin-auth N4 (nit): the reset-password page, the set-password page and the dev-admin row look the code up inline and skip the N5 (nit, accepted): No must-fix. S1 and S2 are fixes to prose faces and one comment. Implemented-by: VERDICT: PASS |
…l and pin them Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Contract reviewServed-tier: Delta round by the reviewer of record 7219466980 (PASS at Tier owed: with ① Derived judgments
② Semver level
③ Boundary flags
FindingsFindings of record 7219466980, at this head: S1 (should-fix): closed.
S2 (should-fix): closed.
Nits, none with an effect on correctness or the contract:
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK 维护者速读
席位核对 — ACCEPT · repo:objectstack#6 · head
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Landing: seat ACCEPT 7220076480 and contract review PASS 7220035689 at head |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46011283514 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Queue ejection triage (run 46011283514): the failing test is |
Fixes #34171
Clause-②: yes (widening) —
@object-ui/authForgotPasswordFormPropsgains the optionalerrorMessages;@object-ui/i18ngainsauth.login.errors.managedPasswordSignInandauth.login.errors.managedPasswordResetin every localeMetadata-protocol: none
维护者速读
What changes
On
origin/main, a cloud-managed runtime refuses the password doors with 409RESOURCE_CONFLICT, and the code never reached the pages. The hosted relay (auth-proxy-plugin.ts, every password door) and plugin-auth's set-initial-password route (cloudManagedRefusal) answer in the ADR-0112 envelope,{ success: false, error: { code, message } }. better-fetch spreads that body, so its code and message arrive nested undererror.error, andtoAuthErrorread only the top level. plugin-auth's reset doors throw better-auth'sAPIErrorfrom the before hook, a flat body with the code. There the code was dropped by the call site:forgotPasswordandresetPasswordthrew a barenew Error(message). So sign-in, forgot, reset and set-password showed the server's English sentence orAuth request failed with status 409, whatever the language, and no host map could localize a code that never arrived. The fix is on the producer side of the client boundary first, then the localized copy.ui/packages/auth/src/createAuthClient.ts, thetoAuthErrorhunk:code,message,detailsanduserMessageare read from the flat body first and from the envelope'serroronly when the flat body has none. A better-auth refusal answers exactly as before. The same file already reads both shapes inacceptInvitationOneStep(body.code ?? body.error.code).forgotPassword,resetPasswordandsetInitialPasswordnow throw throughtoAuthError, so they keep the code and status. Their message fallbacks are unchanged. TheupdateUserhunk andtypes.ts(open PR fix(auth)!: createAuthClient().updateUser declares a void result, matching better-auth's receipt #37433) are untouched, and the two PRs merge in either order.ui/packages/auth:ForgotPasswordFormgainserrorMessages, the same code-to-text mapLoginFormtakes. The lookupLoginFormused is moved, unchanged, torefusal-text.tsand shared.ui/packages/app-shell:signInRefusalMessagesmapsRESOURCE_CONFLICTtoauth.login.errors.managedPasswordSignIn, which says the deployment signs you in through its identity provider and points at the button above. The new exportedpasswordDoorRefusalMessagesmaps it toauth.login.errors.managedPasswordResetfor the forgot, reset and set-password doors. Three plugin-auth producers answer that code there, and the map's comment names them:cloud-managed.ts, and two that a self-hosted deployment answers too.sso-only-local-password.tsrefuses an account the identity provider provisions while SSO-only mode is on, andpending-sso-marker.tsrefuses a pending SSO person. The sentence (you sign in through the identity provider, and no password is set or reset here) is true for all three readers, so the mapping stands for them. It is kept separate on purpose, because the sign-in map's two-factor sentences (INVALID_CODE, and so on) would be wrong on a reset door. The package's forgot-password page passes it.ui/apps/console: the forgot-password page passes the map, and the reset-password and set-password pages map the toast's description through it.ui/packages/i18n: two keys in every locale (the key-parity test requires all eleven). The zh-Hant entries come fromgen:zh-hant.Read first (by risk):
ui/packages/auth/src/createAuthClient.ts, thetoAuthErrorhunk: the read order (flat first, envelope second) is what keeps every better-auth refusal unchanged.ui/packages/auth/src/createAuthClient.ts, thesetInitialPasswordhunk: it now throws throughtoAuthErrorwith its old status-line fallback, so it also carriescodeandstatus.ui/packages/app-shell/src/console/auth/signInRefusalMessages.ts: the two maps and why they are separate.Tests
ui/packages/auth/src/__tests__/managedRefusalEnvelope-34171.test.ts. It drives the real client over a mockedfetch. Each of the four doors rejects with codeRESOURCE_CONFLICT, status 409 and the envelope's message, anddetailsanduserMessagesurvive. Three controls: the flat better-auth body answers as before, the flat body wins when both name a code, and an empty body keeps the status line with no code.ui/packages/app-shell/src/console/auth/__tests__/loginRefusalCodes-11058.test.tsx, new top-level describe. It renders the published login page over a real client in zh. The envelope 409 shows the zhmanagedPasswordSignIn, and neither the server sentence nor the status line appears. CONTROL: another code in the envelope shows its own server message.ui/packages/app-shell/src/console/auth/__tests__/passwordDoorRefusal-34171.test.tsx. The forgot-password page, end to end in zh, shows the localized reset sentence. CONTROL: an unmapped refusal keeps its message. A map-shape pin checks that the reset map carries no sign-in sentence.ui/packages/auth/src/__tests__/forgot-password-success-message.test.tsx, new describe:ForgotPasswordFormmaps by code. Two controls: an unmapped code, and no map at all.ui/apps/console/src/pages/auth/__tests__/passwordDoorRefusal-34171.test.tsx: the reset-password and set-password pages show the localized sentence. CONTROL: another code keeps its server message. A further describe pins the self-hosted SSO-only refusal (plugin-auth's ownSSO_ONLY_REFUSAL_MESSAGEStext) on both pages: it shows the same mapped sentence.Reverse validation (one-off, no test file kept):
scripts/ablation-replace.mjsreplaced the envelope read with an empty object (anchor 1 to 0, blob d7821627 to f40658a6). The envelope pins and the app-shell end-to-end pins went red:Tests 8 failed | 18 passed (26). Restored: blob equals HEAD (d7821627) andgit diff HEADis empty. These tests import from source, so nodist/was in the path.Acceptance notes
RESOURCE_CONFLICT, so a self-hosted sign-in is unchanged. On the reset and set-password doors, a self-hosted deployment in SSO-only mode, or a pending SSO person, now sees the localized sentence in place of plugin-auth's English one. That is deliberate (contract review 7219466980, S2): the sentence is true for that reader.postPhoneNumberEndpoint) still read only the flat body. The hosted relay notes that the phone-number plugin is not mounted on a hosted runtime, so no managed refusal reaches them. Left as is.createAuthClient.ts(toAuthErrorhunk), app-shell, i18n and the console pages. RoutingforgotPassword,resetPasswordandsetInitialPasswordthroughtoAuthErroris three call-site lines outside that hunk. They are needed for the reset doors to carry the code, and they do not touch theupdateUserhunk.Verification
Two-minute check:
cd ui && pnpm exec vitest run packages/app-shell/src/console/auth/__tests__/loginRefusalCodes-11058.test.tsx. Expect all tests green, includinga cloud-managed password refusal is localized.Rework round (head e28f645)
Clause-②: yes (widening)(S1). The changeset and this body correct the self-hosted claim and the mechanism sentence (S2, N3). ThepasswordDoorRefusalMessagescomment names the three producers. A new SSO-only pin was added. No runtime code changed.vitest runof the five touched test files:Test Files 4 passed,Tests 41 passed. The console file then failed to load until@objectstack/clientwas built. After that build, the console file alone:Test Files 1 passed (1),Tests 6 passed (6),VERDICT command-exit 0.Package tests, type-check and build (head fe59df0)
pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' --filter '@object-ui/console^...' build,VERDICT command-exit 0.pnpm --workspace-concurrency=2 --filter @object-ui/auth --filter @object-ui/i18n --filter @object-ui/app-shell --filter @object-ui/console type-check,VERDICT command-exit 0(auth, i18n and app-shell include their test tsconfig; console includessrc).vitest run packages/auth/ packages/i18n/ packages/app-shell/src/console/auth/: the first run was red only onzh-hant-generated(zh-Hant was hand-written), fixed by regenerating. Thenpackages/i18n/:Test Files 107 passed (107),Tests 1867 passed | 13 skipped.pnpm --filter @object-ui/console test:Test Files 339 passed (339),Tests 3711 passed (3711),VERDICT command-exit 0.src/console/auth/. The full suite is CI's.Derived gate families (dispatch-gates --commands, 42)
pnpm --dir ui exec vitest run scripts/was SIGKILLed for memory on its first run, while the console suite ran beside it. Rerun alone, it exited 0:Test Files 172 passed | 2 skipped (174).dispatch-gates --ran:42 derived, 42 run, 0 NOT-MEASURED, 0 UNRUN.Generated by Claude Code