Repository navigation
Commit 568d416
fix(objectql): the duplicate-record refusal reaches the writer's locale on the action door and on bulk rows (#34304)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbSUQWB2j9eHYsRcrCiq1X1C)_
Fixes #33790
Clause-②: yes (widening). The /data 409 and the row errors gain a
`userMessage` key, with the same text as the end-user sentence.
`message` keeps its diagnostic text.
Metadata-protocol: none
## 维护者速读
-
改了什么:记录重复的提示句(如「已存在「工厂」、「牌号」、「成本周次」均相同的记录」)现在在按钮动作、脚本动作、批量编辑和流程里也按用户语言显示,不再只有表单保存才是中文。
- 为什么改:之前通过动作按钮或批量编辑保存时,用户看到的是给工程师看的英文诊断句;席位裁决 B′(6895764754)按维护者裁决
C(6819749037)由错误的产生方统一声明用户句。
- 风险与回滚:只新增一个已有契约字段 `userMessage`,原有 `message`、`error`、`code`
文字不变;回滚即撤回本 PR。
- 先看:`packages/objectql/src/duplicate-record-error.ts`(新增
`userMessage`)、`packages/metadata-protocol/src/protocol-client-failures.ts`(批量行错误带上它)、新测试文件。
- 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run --project
local src/duplicate-record-user-message-doors-33790.test.ts`,预期 20
个用例全绿(中文与英文两套)。
- 需要你做的:无,席位落地。
## What changes
- `DuplicateRecordError` (`@objectstack/objectql`) declares its
already-assembled end-user sentence, composed in the writer's locale, as
`userMessage`. `endUserMessage` keeps the same text. `message` stays the
diagnostic sentence. The module note that said the sentence was
deliberately not `userMessage` is replaced by the B′ rule.
- `toRowApiError` (`@objectstack/metadata-protocol`) carries a
producer-declared `userMessage` on a row error, through the same read
and bound the `/data` door applies (`boundedDeclaredUserMessage`). A row
whose producer marked nothing carries no `userMessage`.
- The sentence names fields by label and quotes no record value, as
before.
Every door, changed or declared unchanged (measured on the real stack
unless noted):
| door | code changed here | wire change | pin |
|---|---|---|---|
| `POST`/`PATCH /data/:object` 409 | no | gains `userMessage`, same text
as `error` | card file, the flipped
`engine-duplicate-record-label-sentence.test.ts` pin, and the three rest
pins |
| `POST /data/:object/createMany` (whole-request 409) | no | gains
`userMessage` beside `error` | card file |
| `POST /actions/...`, declarative `operation: 'update'` | no | gains
`error.userMessage`; `message` unchanged | card file |
| `POST /actions/...`, sandboxed script body writing through `ctx.api`
(QuickJS hand-back) | no | gains `error.userMessage`; the hand-back
keeps it | card file |
| `POST /data/:object/updateMany` rows | yes (`toRowApiError`) | rows
gain `userMessage`; `message` unchanged | card file |
| `POST /data/:object/batch` rows (`create`, `update`, `upsert`) | yes
(`toRowApiError`) | rows gain `userMessage` | card file |
| Hono handler-throw seam (`declaredEnvelopeForThrow`) | no | gains
`error.userMessage` | card file, seam asked directly |
| MCP tool error (`actionsDoorAnswerOf`) | no | gains `userMessage` |
card file, resolver asked directly |
| Flow inner refusal (`refusalCarriedBy`; the trigger and resume doors)
| no | gains `userMessage`; `message` and `innerRefusal.message`
unchanged | flipped `service-automation/src/flow-inner-refusal.test.ts`
and `verify/src/automation-flow-inner-refusal.test.ts` (zh-CN and en) |
| Import rows (`@objectstack/core` import runner) | no | none: the row
adopts the `/data` verdict's `error`, already in the writer's locale |
none |
## Tests
- New
`packages/runtime/src/duplicate-record-user-message-doors-33790.test.ts`:
a real kernel over its Hono app (ObjectQL on sqlite-wasm, REST,
dispatcher, auth, security, an app with a declared composite unique
index, `zh-CN` labels, a declarative update action and a sandboxed
script action). Every door above runs under `Accept-Language: zh-CN` and
under an `en` control, with a control row error that carries no
`userMessage`. 20 tests.
- Flipped
`packages/objectql/src/engine-duplicate-record-label-sentence.test.ts`
(the `not.toHaveProperty('userMessage')` pin) to assert `userMessage`
equals `error`, en and zh-CN.
- Flipped the flow door's two pins (claim amendment 6907854103):
`packages/services/service-automation/src/flow-inner-refusal.test.ts`
(the unique case, now zh-CN and en) and
`packages/verify/src/automation-flow-inner-refusal.test.ts` (the unique
cases at the trigger and resume doors, now zh-CN and en). Each asserts
the run carries the declared `userMessage` and that `message` keeps the
diagnostic.
- Added `userMessage` (equal to `error`) to the expected bodies of seven
exact-shape pins on the /data 409 and row errors (claim amendment for
the rest surface): `packages/rest/src/rest-duplicate-record-arm.test.ts`
(four cases),
`packages/rest/src/data-package-scoped-refusal-candidates.test.ts` (the
two CONTROL cases, flat 409 and row) and
`packages/rest/src/error-response-structured-arm-door-parity.test.ts`
(the DUPLICATE_RECORD door-parity row).
- Added `userMessage` (equal to `error`) to the expected 409 bodies of
the sku and gsku cases in
`packages/qa/dogfood/test/field-unique-rest-refusal.dogfood.test.ts`,
the eighth exact-shape pin (claim amendment 6911413595). It pinned the
flat `/data` 409 by exact shape and ejected the first enqueue (queue run
43826455262); the dogfood shards run only in the queue.
<details><summary>Ablation (both legs rebuilt the package, proved the
marker in dist/, then restored and proved it absent)</summary>
- Producer declaration (`this.userMessage = this.endUserMessage`
replaced by a blank string): 19 of 20 card tests red, for example
`AssertionError: expected undefined to be '已存在「工厂」、「牌号」、「成本周次」均相同的记录'`
on the sandboxed script action. The one green is the control row.
- Row carry (the `userMessage` spread in `toRowApiError` disabled):
exactly the 8 row tests red (`updateMany` and the three `batch`
operations, both locales); the 12 others stay green.
- Producer declaration again, against the flow pins: the 2 unique cases
of `flow-inner-refusal.test.ts` and the 4 unique cases of
`automation-flow-inner-refusal.test.ts` red (`expected undefined to be
'已存在相同客户名称的记录'`); every other case green.
- Restore: blob equals HEAD, `git diff HEAD` empty, dist preflight
`--absent` exit 0, `git status --porcelain` empty.
</details>
## Acceptance notes
- The flow door's existing pins asserted that the engine's duplicate
carries no `userMessage`; ruling B′ turns that false, so they are
flipped here under claim amendment 6907854103.
- The dogfood battery is CI's (no `!` in the title, no `(narrowing)`
arm).
## Verification
<details><summary>Local runs</summary>
- Final head `da832b2f8` (after merging `origin/main` again): card file
20/20; `@objectstack/service-automation` 284 files, 4041 tests passed;
`@objectstack/verify` 52 files, 441 passed; typecheck of
service-automation and verify exit 0.
- Head `fd810dc0e`: `@objectstack/objectql` 599 files, 13353 passed;
`@objectstack/metadata-protocol` 344 files, 22946 passed, 45 skipped;
typecheck of objectql, metadata-protocol and runtime exit 0. Head
`3f7c473bc`: `@objectstack/scenarios` 34 files, 922 passed.
- Pre-merge head `5b4d1738b`, the other direct dependents of objectql
and metadata-protocol: runtime 606 files, 11090 passed, 19 skipped; cli
`unit` 423 files, 6010 passed; plugin-sharing, plugin-audit,
plugin-webhooks, plugin-email, plugin-pinyin-search, plugin-dev,
cloud-connection, example-todo, example-embed-objectql green.
- Head `099761b68` (the rest pin flips): `@objectstack/rest` `test` 413
files, 8497 passed, 350 skipped; `test:repo` 5 files, 300 passed, 23
skipped; typecheck exit 0.
- Gates: `dispatch-gates --commands` on `da832b2f8` derived 71 families;
69 run locally, all exit 0, plus `pnpm lint` exit 0. The gates that read
test files (`check:test-source-alias`,
`check:cross-package-test-inputs`, `check:nul-bytes`,
`check:error-code-casing`, `check:issue-citations`,
`check:tier-file-adoption`) re-run on `099761b68`, exit 0.
`check:dual-build-cjs-loads` and `check:type-check-debt` are left to CI
(`Lint & Repo Gates` success on `099761b68`; `check:type-check-debt`
also exit 0 locally on `3f7c473bc`).
- CI on `099761b68`: every required context is success (Lint & Repo
Gates, TypeScript Type Check, Test Core 1-8/8, Build Core, Governed
Surface Queue Guard, Test UI, Live E2E UI, Dogfood Regression Gate,
Check Changeset); the UI build, lint and type-check lanes were skipped
by path.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5nNrLRm8ssuwWcBVcw -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2c96e0d commit 568d416
11 files changed
Lines changed: 418 additions & 16 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- objectql/src
- qa/dogfood/test
- rest/src
- runtime/src
- services/service-automation/src
- verify/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
158 | 168 | | |
159 | 169 | | |
160 | 170 | | |
| |||
166 | 176 | | |
167 | 177 | | |
168 | 178 | | |
| 179 | + | |
169 | 180 | | |
170 | 181 | | |
171 | 182 | | |
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
| |||
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
186 | | - | |
| 191 | + | |
187 | 192 | | |
188 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| |||
207 | 217 | | |
208 | 218 | | |
209 | 219 | | |
| 220 | + | |
210 | 221 | | |
211 | 222 | | |
212 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
| |||
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
| 431 | + | |
428 | 432 | | |
429 | 433 | | |
430 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| |||
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| 242 | + | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| 290 | + | |
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
| |||
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
| 393 | + | |
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
| |||
570 | 573 | | |
571 | 574 | | |
572 | 575 | | |
| 576 | + | |
573 | 577 | | |
574 | 578 | | |
575 | 579 | | |
| |||
0 commit comments