Repository navigation
fix(console): invitation refusals read in the console's language - #33679
Conversation
get-invitation's code-less not-found answer (a 400 with no code) now reads as the localized not-found sentence, keyed on the route, the status and the missing code, never on the vendor's English. The auth client carries the HTTP status on the thrown error so the page can see it. USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION joins the org error map with a sentence in every locale pack, and the not-found sentence now names the used, expired and revoked states and where an accepted invitation's organization is. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nwxuShQ1A7T6jAiLn
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nwxuShQ1A7T6jAiLn
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nwxuShQ1A7T6jAiLn
…dening Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nwxuShQ1A7T6jAiLn
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Contract reviewServed-tier: Inputs read: card #33650 body and all six comments (triage 6889355499, claim 6889553393, amendments 6889564701 and 6890161273, os-dev-report 6890090496), PR #33679 body and its 18-file list, the net diff ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD 席位核对Verdict: ACCEPT · head
|
|
domain:ui#1 · os-project-manager · session_01FEkQ5nWoa1Ze1QzjRTSYXD Landing · head
State: ready + auto-merge. |
Requested by Leehom · project thread
domain:ui#1 · os-project-manager · session_01FEkQ5nwxuShQ1A7T6jAiLn
Fixes #33650
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
get-invitation对「找不到」只回 400 加一句英文,不带错误码,控制台按错误码翻译所以漏掉了;「已是成员」这个错误码也没有映射。已接受过的邀请再打开,服务端的回答和「找不到」完全一样,控制台无法区分,所以改为在同一句话里说明「可能已被使用」并指向组织列表(页面原有的「前往组织」按钮)。get-invitation+ 400 + 无错误码」这一种回答,不读英文原文;其他 400(带错误码的)和 401 等仍照旧显示服务端原句。@object-ui/auth抛出的错误多带一个status字段,原有字段与文字不变。服务端不改。回滚即 revert 本 PR。ui/packages/app-shell/src/console/organizations/orgErrorMessage.ts的resolveInvitationLookupMessage;ui/packages/auth/src/createAuthClient.ts的toAuthError一行;ui/packages/i18n/src/locales/zh-Hans.ts的两句中文。pnpm --dir ui exec vitest run packages/app-shell/src/console/organizations/__tests__/invitationVendorRefusals-33650.test.tsx,预期 9 个用例全绿。What changes
GET /organization/get-invitation(dist/plugins/organization/routes/crud-invites.mjs,getInvitation) throwsAPIError.fromStatus("BAD_REQUEST", { message: "Invitation not found!" })with nocodefor an unknown id and for an invitation that is accepted, rejected, canceled or expired. Every other 400 the route answers names its code (ORGANIZATION_NOT_FOUND,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION, better-call'sVALIDATION_ERROR). The newresolveInvitationLookupMessage(orgErrorMessage.ts) reads exactly that answer, keyed on the route (onlyAcceptInvitationPage'sgetInvitationcatch calls it), status 400 and the missing code, and never on the English text (the module's rule, objectui#4474). Anything else goes throughresolveOrgErrorMessageas before.@object-ui/authcarries the HTTP status.toAuthErrordroppedstatus, so the page could not see the 400. It now copies a numericstatusonto the thrown error, like the two-factor and invitation-preview errors in the same file already do.message,codeand the rest are unchanged.AuthClientErroris a module-internal type; no exported type changes.USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATIONjoinsORG_ERROR_MESSAGE_KEYSasorganization.errors.alreadyMember, with a sentence in all 11 packs (10 hand-written,zh-Hantgenerated bygen:zh-hant).Tests
ui/packages/app-shell/src/console/organizations/__tests__/invitationVendorRefusals-33650.test.tsx(new, 9 cases): the REALAcceptInvitationPageandInviteMemberDialogunder the realI18nProvider, withuseAuthforwarding to the REALcreateAuthClientover a stubbedfetchthat answers better-auth 1.7.12's own bodies. Faces 1 (zh and en), 2 and 3, the pack census for the new key, and four CONTROLs: a coded 400 from get-invitation keeps its own message; a code-less 401 keeps its own message;accept-invitation's codedINVITATION_NOT_FOUNDstill maps as before; an unmapped coded invite refusal keeps the server's sentence.ui/packages/auth/src/__tests__/authErrorStatus-33650.test.ts(new, 2 cases): the real client carriesstatuson a code-less and on a coded refusal, message unchanged.orgErrorMessage-4474.test.ts: the mapping-table census names the new code.Acceptance notes
pendingwith the same code-less 400,list-user-invitationsfilters topending, and objectstack's signed-outinvitation-previewanswers one uniform 404 by design (ADR-0138 D2). The console could only find the invitation by listing invitations of every organization the user belongs to (list-invitationsreturns all statuses to a member), which is new fan-out fetching, not data the page already has, so the order's fallback applies: the sentence covers used / expired / revoked and points to the organization list. A server answer that tells a signed-in recipient "you already accepted this, organization X" is reported for a server card.yes (widening)(seat reading, as for PR fix(console, i18n): the default app's Set-default star on Setup → Apps says why it is disabled #33485 and PR fix(console): a link refused as already linked to another user, or as unable to link, says why where the signed-in person lands #33585):@object-ui/i18ngainsorganization.errors.alreadyMemberin all eleven locale packs (and rewordsorganization.errors.invitationNotFound), and errors thrown by@object-ui/authgain a numericstatusproperty besidemessageandcode. Nothing is removed or narrowed; no exported type changes (AuthClientErroris module-internal).resolveInvitationLookupMessageis a separate entry point rather than a status rule insideresolveOrgErrorMessage: only the caller knows which route it called, and a code-less 400 from another organization route is not a not-found.Verification
All local readings at head
2c555217(the later head only changes the changeset's declaration line and prose; the changeset gates were rerun on it: check-changeset-no-major, check-empty-changeset, check-adr-0087-registration and its self-test, changeset-gate-self-tests, nul-bytes, all exit 0) (base3c0033f9;origin/mainhas moved 20 commits since, none touching these files).Measurement on base: all three faces reproduce
Production sources put back to
3c0033f9(tests kept), the new pins run, thengit checkout HEAD --restored (git diff HEADempty):Deciding lines on base: face 1 and 3,
orgErrorMessage.ts:191(resolveOrgErrorMessagereturns the non-empty message verbatim because the error has no code) behindcreateAuthClient.ts:195(toAuthErrorkeepscode, dropsstatus), called fromAcceptInvitationPage.tsx:84; face 2,ORG_ERROR_MESSAGE_KEYShas noUSER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATIONrow (invite section,orgErrorMessage.ts:89-100). Face 3 is the same wire answer as face 1: better-auth refuses any status butpendingwith the code-less 400.Head: new pins and affected suites
Ablations: each new branch, its pins red, restored to the HEAD blob
node scripts/ablation-replace.mjsper leg (ui vitest reads these packages from source, so no dist leg):The first A3 attempt was refused before running (anchor ambiguous, 2 hits, exit 3, nothing mutated); rerun with a three-line anchor.
Derived gates (39), dispatch-gates --ran: 39 derived, 39 run, 0 NOT-MEASURED
Human Minimum
packages/specholds no runtime logic. (no spec change)pnpm lintpasses. (no formatter ran;pnpm lintwas not run locally, the repo-wide lint run is CI's)main, one pull request..changeset/33650-invitation-refusal-copy.md)packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code