Repository navigation
Commit a91409c
fix(core,react,i18n,components,console): a refused write on a read-only external object says the table is read-only, not that you lack permission (#30403)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg94yb5pVXBLeYzq5skXAbtg)_
domain:ui#3 · os-bill · session_01Utp6CbPN5UYMnBaNJPJWfG
## 维护者速读
- 改了什么:对外部只读表(数据源 allowWrites/对象 writable 不全为
true)写入被服务端拒绝时,新建/编辑表单、记录对话框、记录删除、列表行删除、行内编辑、日历拖动改期、阶段切换七处都改为提示「这张表是只读的:它的记录来自外部数据源,不接受修改。」(十种语言)。
- 为什么改:以前提示「您没有权限保存这条记录」或直接甩出英文诊断原文,管理员会去翻权限集,而任何权限集都解不开这张表。
- 风险与回滚:只按服务端错误码 EXTERNAL_WRITE_FORBIDDEN 换文案,其他 403 和其他错误一字不变;回滚即撤本 PR。
- 先看:ui/packages/core/src/utils/external-write-refusal.ts(判定只读
code)、ui/apps/console/src/components/FormPage.tsx 的
refusalText、ui/packages/core/src/actions/recordDelete.ts 的失败 toast。
- 两分钟验证:examples/app-showcase 跑 `objectstack dev --seed-admin
--fresh`,打开 External Customers 点「新建」填名称后创建,横幅应为上述只读提示,不再是「您没有权限保存这条记录。」
- 需要你做的:无,席位落地。
Refs #30334 (item 2)
Clause-②: yes (widening)
Metadata-protocol: none
## What changes
Item 2 of the card: "If a write still reaches the server, the message
says the table is read-only, not that the user lacks permission."
The ADR-0015 write gate (objectql `assertWriteAllowed`) refuses a write
on an object bound to an external datasource unless
`datasource.external.allowWrites` AND `object.external.writable` are
both true. Measured on a live boot (app-showcase, object
`showcase_ext_customer` on datasource `showcase_external`): `POST`,
`PATCH` and `DELETE` on `/api/v1/data/showcase_ext_customer` each answer
`403` with `{"error":"Write 'insert' blocked on object
…","code":"EXTERNAL_WRITE_FORBIDDEN","object":"showcase_ext_customer"}`.
- **`@object-ui/core`: `isExternalWriteRefusal(err)`**, re-exported from
`@object-ui/react` beside the other write-refusal readers. True only for
the code the spec declares as `EXTERNAL_ERROR_CODES.writeForbidden`,
read from `code` then `details.code` (the pair `isPermissionError`
reads). It reads the server's verdict only; it re-derives nothing from
the two flags.
- **`@object-ui/i18n`: `form.readOnlyExternalSource`** in all ten packs.
- **Every surface that met this refusal now says it**, asked before
`isPermissionError` (which claims every 403):
- console record form page (`FormPage` `refusalText`), and the record
dialog (`@object-ui/components` form) used by the list's 新建 and by 编辑;
- record page header delete (`RecordDetailView`) and list row delete
(`@object-ui/core` `recordDelete`), which showed the gate's raw English
diagnostic;
- record page inline edit (`InlineEditSaveBar`), which pinned the raw
diagnostic on the edited field; now the read-only line, no field marked;
- calendar drag-to-reschedule (`ObjectCalendar`) and record path stage
change (`stageRefusalLines`), same class, not walked live.
Not in this PR (seat ruling on the claim): hiding New / Import / Edit /
Delete on such an object is #30370 (the served `/auth/me/permissions`
entry for the object reads `allowCreate/allowEdit/allowDelete: true` and
`apiOperations` includes `create`, `update`, `delete`, `import`:
`buildEffectiveObjectPermissions` never reads the ADR-0015 gate), and
the 在队列中 filter is #30372 (the spec plans the injected `queue` column on
external objects too).
## Tests
- `FormPage.externalWriteRefusal-30334.test.tsx`: the form page's banner
and toast for the gate's envelope, en and zh, plus a PERMISSION_DENIED
control.
- `form-write-error-external-30334.test.tsx`: the record dialog, `code`
and `details.code`, plus a FORBIDDEN control.
- `error-message.externalWriteRefusal-30334.test.ts`: the predicate,
with controls (other 403 codes, `EXTERNAL_WRITE_REFUSED` 422, the gate's
text without its code).
- `stageRefusalLines.externalWrite-30334.test.ts`: the stage change
lines, with a control.
## Acceptance notes
- Kanban card moves (`plugin-kanban`) read the refusal the same way and
are left alone: that package is held by the in-flight #30220 claim.
- Flow runs whose write node meets the gate already say the server's own
sentence, not the permission line (`flowFailureMessage` reads the inner
refusal's text when `isPermissionError` is false for a status-less
refusal); not changed.
- Bulk delete reports a count summary only; not changed.
## Verification
Live walk: `examples/app-showcase`, `objectstack dev --seed-admin
--fresh -p 4630`, console Vite against it, zh locale, signed in as the
seeded admin. "Before" is the same boot with this PR's eight source
files checked out at `fdad1786` (restored afterwards, `git diff HEAD`
empty). Screenshots are in the project files under `ui-seat3/30334/`.
| Surface | Before | After |
|---|---|---|
| 新建 → 创建 (`*-3-create-refused.png`) | 您没有权限保存这条记录。 |
这张表是只读的:它的记录来自外部数据源,不接受修改。 |
| 编辑 → 保存 (`*-4-edit-refused.png`) | 您没有权限保存这条记录。 | same read-only line
|
| record header 删除 (`*-6-delete-refused.png`) | Write 'delete' blocked
on object 'showcase_ext_customer': datasource 'showcase_external' is
external … | same read-only line |
| list row 删除 (`*-7-row-delete-refused.png`) | 删除 External Customer 失败 +
the raw diagnostic | 删除 External Customer 失败 + the read-only line |
| inline edit 保存 (`*-9-inline-edit-refused.png`) | the raw diagnostic,
on the field | the read-only line, no field marked |
The source table was not changed by any of these writes (the gate
refused each).
<details><summary>Targeted vitest at 7647399 (199 files: the new tests,
every test importing a changed module, the i18n package's tests; the
later merge of main and the changeset fix touch no ui file)</summary>
```
Test Files 199 passed (199)
Tests 2191 passed | 90 skipped (2281)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Type-check at 7647399</summary>
`pnpm exec turbo run type-check --filter=@object-ui/core
--filter=@object-ui/react --filter=@object-ui/i18n
--filter=@object-ui/components --filter=@object-ui/plugin-calendar
--filter=@object-ui/plugin-detail --filter=@object-ui/app-shell
--filter=@object-ui/console --concurrency=2`: `Tasks: 81 successful, 81
total`, VERDICT command-exit 0.
</details>
<details><summary>Gates</summary>
At ae3c67c, `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 35 families; each was run and its
exit code recorded before any pipe, then reconciled:
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
```
`dispatch-gates --ran`: 35 derived, 35 run, 0 NOT-MEASURED. `node
scripts/check-sdui-manifest.mjs` is among them. `pnpm --dir ui
check:new-line-citations`: 0 new citations.
The `Lint UI` red on `check:liveness` naming `query/searchFields` is
main's (#30367), not this change's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CajiubyEqtA9TdrtCf)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent efcc1a7 commit a91409c
27 files changed
Lines changed: 460 additions & 15 deletions
File tree
- .changeset
- ui
- apps/console/src/components
- packages
- app-shell/src/views
- components/src
- __tests__
- renderers/form
- core/src
- actions
- utils
- i18n/src/locales
- plugin-calendar/src
- plugin-detail/src
- renderers
- __tests__
- react/src
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| |||
2077 | 2078 | | |
2078 | 2079 | | |
2079 | 2080 | | |
2080 | | - | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
2081 | 2085 | | |
2082 | 2086 | | |
2083 | | - | |
2084 | | - | |
| 2087 | + | |
| 2088 | + | |
2085 | 2089 | | |
2086 | | - | |
| 2090 | + | |
2087 | 2091 | | |
2088 | 2092 | | |
2089 | 2093 | | |
| |||
2098 | 2102 | | |
2099 | 2103 | | |
2100 | 2104 | | |
| 2105 | + | |
2101 | 2106 | | |
2102 | 2107 | | |
2103 | 2108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
4641 | 4641 | | |
4642 | 4642 | | |
4643 | 4643 | | |
4644 | | - | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
| 4647 | + | |
| 4648 | + | |
| 4649 | + | |
| 4650 | + | |
| 4651 | + | |
4645 | 4652 | | |
4646 | 4653 | | |
4647 | 4654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
503 | 505 | | |
504 | 506 | | |
505 | 507 | | |
| |||
3218 | 3220 | | |
3219 | 3221 | | |
3220 | 3222 | | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
3221 | 3226 | | |
3222 | 3227 | | |
3223 | 3228 | | |
3224 | 3229 | | |
3225 | 3230 | | |
3226 | 3231 | | |
3227 | 3232 | | |
3228 | | - | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
3229 | 3236 | | |
3230 | 3237 | | |
3231 | 3238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
275 | 283 | | |
276 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
277 | 287 | | |
278 | 288 | | |
279 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
0 commit comments