Repository navigation
Commit 555eb1b
fix(objectql): the record-currency backfill cleans a driver's raw text out of a failed row, as the import door does (#30867)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DX44Uu3BZcP1g6vzpMCUtzN)_
domain:server#1 · os-elon-musk · session_016WV4d1GEfMtjCJfYePyAPD
Fixes #30816
Clause-②: no
Metadata-protocol: none
Claim: comment 6678760289 (branch `claude/project-thread-x3bsoc`).
## 维护者速读
- 改了什么:记录币种回填(`POST /api/v1/meta/_migrate-record-currency-codes` 与 `os
migrate record-currency-codes`)报告里失败行的错误文字,非沙箱钩子的报错现在先经导入入口同一个清洗函数
`sanitizeRowError` 再返回。
- 为什么改:回填报告自 #30809 起经 REST 返回给持 `setup.write` 的租户管理员,数据库驱动的原始报错(SQL
语句、约束名、列名)会原样外露;导入入口早已清洗同类报错。
- 风险与回滚:只改一行取值,沙箱钩子分支不动;不含驱动文字的报错照旧原样;运维日志行仍保留完整原文。单一提交可整体回滚。
-
先看:`packages/objectql/src/record-currency-backfill.ts`(`rowFailureSentence`
的最后一行)、`packages/rest/src/meta-record-currency-backfill-route.test.ts`(REST
钉)。
- 两分钟验证:`pnpm --filter @objectstack/objectql exec vitest run
src/record-currency-backfill.test.ts`,预期 21/21 通过。
- 需要你做的:无,席位落地。
## What changes
- `rowFailureSentence` (`@objectstack/objectql`): a row whose write
threw anything other than a sandboxed hook's error now reads
`sanitizeRowError(message)`, the import row's rule from
`@objectstack/core`, instead of the raw message. The sandboxed arm (the
door's withheld sentence for a crash, the hook's own sentence for a
refusal) is unchanged. The operator's `logger.warn` line still carries
the whole text.
- No new export and no new dependency edge: `sanitizeRowError` is
already public (`packages/core/src/index.ts` re-exports
`./utils/import-runner.js` with `export *`; `@objectstack/rest` tests
already import it from `@objectstack/core`), and `@objectstack/objectql`
already depends on `@objectstack/core`. So the card's premise that core
does not export it does not hold, and `Clause-②` re-derives to `no`
instead of the claim's expected `yes (widening)`. ⛔ No second copy of
the sanitizer's rules.
- The CLI report changes in the same way, because it prints the same
`failures[].error` through `formatRecordCurrencyBackfillReport`. The
operator loses nothing: the CLI routes `logger.warn` to its warning line
(stderr under `--json`), which keeps the raw driver text.
## Why
Since #30809 the backfill report is also the REST answer of `POST
/meta/_migrate-record-currency-codes`, read by a tenant admin holding
`setup.write`. A driver's error kept its SQL statement, constraint name
and column list verbatim in that answer, while the import door cleans
the same class. Contract review 6677255440, should-fix 1.
## Tests
- `packages/objectql/src/record-currency-backfill.test.ts`: three
driver-shaped throws (an `update ... - REASON` statement, a SQLite
UNIQUE failure, an `insert ... - FOREIGN_KEY_REASON` statement) each
read `sanitizeRowError(raw)` in the report and none of the driver's
names; the printed report line reads the same sentence; the warning line
keeps the raw text. The existing CONTROL (a plain message with no driver
text) still reads as before.
- `packages/rest/src/meta-record-currency-backfill-route.test.ts`: on
the real `RestServer` route over a real `ObjectQL` engine, the driver
throws a driver-shaped error for one row of the caller's organization;
the answer is 200, the other row is written, and the failed row carries
`sanitizeRowError(raw)` with no SQL, column or placeholder text.
- Found while writing the REST pin: a unique violation never reaches
`rowFailureSentence` raw, because the engine already rewrites it into
its own duplicate-record sentence. The REST pin therefore uses a
value-too-long driver error.
<details><summary>Ablation (restored, blob equal to HEAD, git diff HEAD
empty)</summary>
- Mutation `?? sanitizeRowError(message);` to `?? (message ||
'ABLATED_30816');` via `scripts/ablation-replace.mjs`, objectql rebuilt,
`ablation-dist-preflight` found the marker in 2 built files (the REST
suite reads objectql's `dist/`).
- objectql: 1 failed / 20 passed (the driver-shaped case). REST: 1
failed / 12 passed (the new pin).
- Restore leg: blob `5fd2c441` equals HEAD, `git diff HEAD` empty,
objectql rebuilt, preflight `--absent` green, both files green again
(21/21, 13/13).
- The mutate leg's objectql build exited 1 after emitting JS (the marker
reached dist); the restore build exited 0.
</details>
## Acceptance notes
- `sanitizeRowError` keeps the trailing reason of a `... - REASON`
driver message when the reason is not itself SQL, so a reason such as
`value too long for type character varying(3)` is still shown. That is
the import door's existing reading, applied here unchanged.
## Verification
All on head `9e4afd8b`:
- `pnpm --filter @objectstack/objectql typecheck` and `test`: 558 files,
11160 tests passed.
- `pnpm --filter @objectstack/rest typecheck` and `test`: 393 files,
7456 passed, 332 skipped.
- `node scripts/pm/dispatch-gates.mjs --commands`: 61 families derived;
`--ran` reconciliation: 60 run with exit 0, 1 NOT MEASURED (`pnpm
check:dual-build-cjs-loads`, exit 3, PREREQUISITE NOT MET: the whole
tree has no `dist/`; CI runs it on a full build).
- `pnpm lint`: exit 0.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [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: 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_016WV4d1GEfMtjCJfYePyAPD)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3e04799 commit 555eb1b
4 files changed
Lines changed: 61 additions & 5 deletions
File tree
- .changeset
- packages
- objectql/src
- rest/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
484 | 485 | | |
485 | 486 | | |
486 | 487 | | |
487 | | - | |
| 488 | + | |
488 | 489 | | |
489 | 490 | | |
490 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
491 | 512 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
457 | 460 | | |
458 | 461 | | |
459 | 462 | | |
460 | | - | |
| 463 | + | |
461 | 464 | | |
462 | 465 | | |
463 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
234 | 256 | | |
235 | 257 | | |
236 | 258 | | |
| |||
0 commit comments