Repository navigation
Commit a1d243e
fix(console): localize the organization-limit refusal in the create-workspace dialog (#31465)
<!-- claude-projects-attribution: {"github_login":"os-zhuang"} -->
_Requested by **Sam** · [project
thread](https://claude.ai/code/project/chan_01GsBogozeZG5sdpAARrN7HP?thread=cmsg_01GsBogozeZG5sdpAARrN7HPFXdEVvapaU7V47g3TwNSXj)_
Closes #28124
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台「新建组织」对话框遇到组织数上限的拒绝(403
`YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS`)时,改为显示当前语言的说明文案,全部
11 个语言包都加了这条。
- 为什么改:cloud 把每人可建组织数降到 2 之后,用户建第 3 个组织时看到的是 better-auth
的英文原句,中文用户看不懂,也不知道被邀请加入的组织不算在内。
- 风险与回滚:只加了一行错误码映射和一个文案键,不碰服务端;回滚就是撤掉这个 PR。文案不写具体数字,因为拒绝响应体和
`/auth/config` 都不带上限值。
-
先看:`ui/packages/app-shell/src/console/organizations/orgErrorMessage.ts`(新增的映射行和注释)、`ui/packages/i18n/src/locales/zh-Hans.ts`(中文文案)、`ui/packages/app-shell/src/console/organizations/__tests__/CreateWorkspaceDialog.test.tsx`(末尾新增的
zh/en 用例)。
- 两分钟验证:在 `ui/` 下跑 `npx vitest run
packages/app-shell/src/console/organizations/__tests__/CreateWorkspaceDialog.test.tsx`,应全绿,其中
zh-Hans 用例显示「您创建的组织数量已达上限。被邀请加入的组织不计入此上限。」
- 需要你做的:无,席位落地。
## What changes
- `orgErrorMessage.ts`: `ORG_ERROR_MESSAGE_KEYS` gains a row for
better-auth's `YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS`,
mapped to the new key `organization.errors.organizationLimitReached`,
with an English `defaultValue`. The header docblock lists the code among
the create-path rows.
- All 11 console packs (`en`, `zh-Hans`, `zh-Hant`, `ja`, `ko`, `de`,
`es`, `fr`, `pt-BR`, `ru`, `ar`) define the key. `zh-Hant` is
regenerated from `zh-Hans` with `pnpm --filter @object-ui/i18n
gen:zh-hant`, not hand-written.
- The sentence says the cap counts only organizations the user created,
never ones they were invited to. That is the part a refused user cannot
guess, and it is how the server counts (`role = owner` rows in
`sys_member`).
- Changeset: `@object-ui/i18n` and `@object-ui/app-shell`, patch.
## Why
The hosted control plane caps self-created organizations at 2
(`OS_ORG_LIMIT`, better-auth `organizationLimit`). A third create is
refused with 403 and the code above. The console had no row for that
code, so `resolveOrgErrorMessage` fell through to the server's English
sentence in every locale.
Work item 2 (name the number only if it is exposed), measured on
objectstack `9728ab15` and cloud `ac69aac`:
- The refusal is thrown at `better-auth@1.7.12`
`dist/plugins/organization/routes/crud-org.mjs:61` as
`APIError.from("FORBIDDEN",
ORGANIZATION_ERROR_CODES.YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS)`.
The body is the bare code and message, with no limit in it.
- The limit is read inside the `organizationLimit` callback
(`packages/plugins/plugin-auth/src/auth-manager-organization-plugin.ts:204`,
`resolveOrgLimit()` at `packages/types/src/env.ts:727`) and returned as
a boolean. The `/auth/config` `features` object
(`packages/plugins/plugin-auth/src/auth-manager.ts:5047` onward) does
not publish it.
- cloud sets the value in the container env only
(`apps/cloud/cloudflare/worker.ts:503`, `OS_ORG_LIMIT: '2'`). Nothing in
cloud adds it to a response.
So the message names no number, and a test holds every pack to that.
## Tests
- `orgErrorMessage-4474.test.ts`, new top-level `describe` for the code:
zh renders the zh pack value (Han script, not the server sentence); en
renders the en pack value; every pack defines the key, its own sentence
differs from `en`, and no pack value contains a digit. The exact-set pin
of mapped codes gains the code.
- `CreateWorkspaceDialog.test.tsx`, new top-level `describe`: through
the real `zh-Hans` and `en` packs, a create refused with the limit code
shows the pack sentence in `workspace-create-error`, not the server's
English, and the dialog neither retries nor provisions.
Ablation (one-off, no permanent file), with
`scripts/ablation-replace.mjs` renaming the mapping row's key so the
code is unmapped: anchor x1 to x0, blob `335e7a7e` to `2050edb8`. 5
tests went red (zh and en in each file, plus the exact-set pin), 33
stayed green. Restore: blob equals HEAD `335e7a7e`, `git diff HEAD`
empty.
## Acceptance notes
- No spec change, no server change.
- `zh-Hant` is a generated catalogue (`zh-hant-generated.test.ts`), so
its sentence is the converter's rendering of the zh-Hans one.
- `check:i18n-dead-keys` lists the new key as `needs-review`, exactly
like its nine siblings in `organization.errors`: the gate cannot read a
key held as a value in a mapping table. It is a report, not a red.
- `Type Check UI` for `@object-ui/app-shell` is left to CI: a local
`type-check` needs every `@object-ui/*` workspace package built first.
## Verification
Local readings, on objectstack-ai/objectstack:
- `node scripts/pm/dispatch-gates.mjs --commands` on head `0ad95797`: 38
derived families, every one run on that head and exit 0. `--ran`
reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN (a derived
zero, every row carries its exit code).
- i18n gates under `ui/`: `pnpm check:i18n-drift` exit 0 (0 en values
changed, 1 key added), `pnpm check:i18n-keys` exit 0, `pnpm
check:i18n-dead-keys` exit 0 (report; see the acceptance note).
- `npx vitest run packages/i18n/
packages/app-shell/src/console/organizations/` under `ui/`, on
`b1443871`'s tree (the last code commit; `0ad95797` adds only the
changeset): 116/116 files, 1967 passed, 13 skipped. This covers
`all-locales-key-parity.test.ts`, `en-zh-key-parity.test.ts` and
`zh-hant-generated.test.ts`.
- Ablation: see Tests.
CI runs every other family on the PR.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (No formatter ran; the
repo-wide lint is CI's run.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QUs3BveKCXohEcrrpsCh6c)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ee610fb commit a1d243e
16 files changed
Lines changed: 146 additions & 3 deletions
File tree
- .changeset
- ui
- packages
- app-shell/src/console/organizations
- __tests__
- i18n/src/locales
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
176 | 223 | | |
177 | 224 | | |
178 | 225 | | |
| |||
196 | 243 | | |
197 | 244 | | |
198 | 245 | | |
| 246 | + | |
199 | 247 | | |
200 | 248 | | |
201 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3870 | 3870 | | |
3871 | 3871 | | |
3872 | 3872 | | |
| 3873 | + | |
3873 | 3874 | | |
3874 | 3875 | | |
3875 | 3876 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3589 | 3589 | | |
3590 | 3590 | | |
3591 | 3591 | | |
| 3592 | + | |
3592 | 3593 | | |
3593 | 3594 | | |
3594 | 3595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4393 | 4393 | | |
4394 | 4394 | | |
4395 | 4395 | | |
| 4396 | + | |
4396 | 4397 | | |
4397 | 4398 | | |
4398 | 4399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3660 | 3660 | | |
3661 | 3661 | | |
3662 | 3662 | | |
| 3663 | + | |
3663 | 3664 | | |
3664 | 3665 | | |
3665 | 3666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3656 | 3656 | | |
3657 | 3657 | | |
3658 | 3658 | | |
| 3659 | + | |
3659 | 3660 | | |
3660 | 3661 | | |
3661 | 3662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3591 | 3591 | | |
3592 | 3592 | | |
3593 | 3593 | | |
| 3594 | + | |
3594 | 3595 | | |
3595 | 3596 | | |
3596 | 3597 | | |
| |||
0 commit comments