Repository navigation
Commit 85ea224
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8N5m96xEWaAue5HPrCydye4)_
Fixes #29645
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no file under `skills/**` or `content/docs/**`
teaches writing a `Date`, `Map`, `Set`, class instance or typed array
into a text-family field (`git grep` of both trees: zero hits), and the
refusal reuses the existing catalog sentence.
## 维护者速读
- **改了什么**:文本类字段(text、textarea、email、url、phone 等 12 种)收到
`Date`、`Map`、`Set`、类实例或类型化数组时,现在一律以 `invalid_type`
拒收,与普通对象、数组已有的拒收同一句话;判定改用选项字段(#29562)已在用的 `isObjectValue`,没有复制新函数。
- **为什么改**:原来的对象判定只认普通对象,其它对象按字符串读法放行:内存驱动把对象原样存下,SQLite 把 `Date` 存成纪元数字
`"1767312000000.0"`,`Map`/`Set` 存成 `"{}"`;email/url/phone 只是碰巧被格式校验拦下。
- **风险与回滚**:是收窄,只影响引擎写入口(流程、钩子、服务端代码);JSON 请求体带不出这些值,REST
调用方无变化。email/url/phone 上这类对象的错误码由格式码变为 `invalid_type`。旧行不改写。回滚即 revert 本
PR。
- **先看**:`packages/objectql/src/validation/record-validator.ts` 字符串分支
`isObjectValue(value)`
那一处;`record-validator.text-object-value.test.ts`;`packages/rest/src/engine-sqlite-text-object-value.test.ts`。
- **两分钟验证**:`pnpm --filter @objectstack/objectql exec vitest run
--maxWorkers=2
src/validation/record-validator.text-object-value.test.ts`,预期 140 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
- `packages/objectql/src/validation/record-validator.ts`, the
`BOUNDED_STRING_FIELD_TYPES` arm: its shape test was
`isPlainObjectValue(value) || Array.isArray(value)`, which is
prototype-strict, so a `Date`, `Map`, `Set`, class instance or typed
array passed on its string reading. It now asks `isObjectValue(value)`,
the option arms' test from #29562, and names the shape with that card's
`receivedObjectShape`: no copy of either. The wire code
(`invalid_type`), the message key (`invalid_value_shape`) and the detail
(`expected a string, received an object` / `an array`) are the ones a
plain object already got. It is still a shape test, ahead of
`shapeOnly`, so a readonly field's value is judged the same way.
- Docblocks only, same file: the file header's string-types line, the
`isObjectValue` / `receivedObjectShape` docblocks, and the #29241 "not
touched" paragraph of `normalizeNumericStringValues` now say "any
object". `normalizeBlankTypedRow` is untouched.
- Changeset `.changeset/29645-text-field-refuses-any-object.md`:
`@objectstack/objectql` patch, BREAKING banner, both declaration lines,
ADR-0087 `not-required (no-migration-prescription)`, FROM / TO and the
remedy.
## Why
Measured on `origin/main` @ `7dae3b3c` (base) and on this branch (head
`2e8ba408`), through the engine's insert, update by id and update by
predicate, on SQLite (the physical column, read with the driver's query
builder) and driver-memory (the engine's read). Twelve types × five
values × three doors × two drivers:
| value | base, 9 types (text, textarea, password, markdown, html,
richtext, code, signature, qrcode): SQLite stored | base, those 9:
memory read | base, email / url / phone | head, all 12, both drivers,
all 3 doors |
|:---|:---|:---|:---|:---|
| `new Date(...)` | `"1767312000000.0"` | the `Date` itself |
`invalid_email` / `invalid_url` / `invalid_phone` | `invalid_type` |
| `new Map(...)` | `"{}"` | the `Map` | same format codes |
`invalid_type` |
| `new Set(...)` | `"{}"` | the `Set` | same format codes |
`invalid_type` |
| a class instance `{ k: 1 }` | `'{"k":1}'` | the instance | same format
codes | `invalid_type` |
| `new Uint8Array([1, 2])` | `'{"0":1,"1":2}'` | the typed array | same
format codes | `invalid_type` |
| plain-string control | stored as sent | as sent | as sent (a valid
address, URL, phone) | stored as sent |
`password` reads back masked on both sides, so its stored column is the
only answer there. The format types refused by accident: `String(value)`
failed their regex. Head refuses the shape first on all twelve, so those
three answer `invalid_type` instead of their format code.
## Tests
- New
`packages/objectql/src/validation/record-validator.text-object-value.test.ts`
(140 cases): the spec set's twelve members pinned by name; each type ×
`Date` / `Map` / `Set` / class instance / typed array × insert / update
refuses with `code` + `constraint.type` + detail; a per-type
plain-string control (a valid address, URL and phone on the three format
types); the message names field, type and shape; the readonly scope
refuses; a number and a boolean keep #29241 (written as their string,
then judged); the door leaves an object as sent; a `json` field still
holds a `Date` or a `Map`; engine insert, insertMany, update by id and
update by predicate answer `VALIDATION_FAILED` and the driver is never
written, with a string control that is.
- New `packages/rest/src/engine-sqlite-text-object-value.test.ts` (6
cases): the same five values on a real `ObjectQL` + sqlite `SqlDriver`,
all three doors refused, the physical row absent or unchanged; control:
a string stored as sent and a number stored as `"42"`.
- No existing test changed.
## Acceptance notes
- Reach is the engine doors only (flows, hooks, server code), as the
card says; REST over JSON cannot carry these values, so no REST pin is
added.
- The `currency` arm's `isPlainObjectValue` (sentence choice only, never
the verdict) is untouched and is the helper's one remaining caller.
- Out of scope, noted not filed: none found.
## Verification
All readings on head `2e8ba408`, base `7dae3b3c`.
<details><summary>Suites</summary>
- `@objectstack/objectql` test: Test Files 544 passed (544), Tests 10741
passed (10741); lock VERDICT command-exit 0.
- `@objectstack/rest` test: Test Files 381 passed (381), Tests 7130
passed, 332 skipped (7462); lock VERDICT command-exit 0.
- `@objectstack/objectql` and `@objectstack/rest` typecheck (both
include `check:test-typecheck`): lock VERDICT command-exit 0.
- `@objectstack/dogfood` (full battery, narrowing arm), after building
the `@objectstack/dogfood^...` closure: Test Files 399 passed, 3 skipped
(402); Tests 3297 passed, 28 skipped (3325); lock VERDICT command-exit
0. No failure.
- `pnpm lint` (`eslint . --no-inline-config`): exit 0.
</details>
<details><summary>Ablation</summary>
`scripts/ablation-replace.mjs` (child mode, trap-armed) put the guard
back to `if (isPlainObjectValue(value) || Array.isArray(value)) {`:
anchor 1 → 0, replacement 0 → 1, blob `7b789eee` → `61b1bb58`. The
objectql file (validator imported from `src`) ran red: Tests 123 failed,
17 passed (140); the 17 green are the controls and leave-alone cases.
The objectql build was then run so the rest pin would read the mutation:
its JS emitted and its DTS step failed (the mutated line hands `unknown`
to `receivedObjectShape`), and `ablation-dist-preflight` found the
marker in 4 built files. The rest pin ran red: Tests 5 failed, 1 passed
(6), the green one being the control. Restore: blob == HEAD `7b789eee`,
`git diff HEAD` empty; rebuild exit 0, `ablation-dist-preflight
--absent` clean on all 14 built files and the tree; the rest pin back to
6/6.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `2e8ba408` derived 60 families; all 60
ran, each exit 0. `--ran` reconciliation: 60 derived, 60 run, 0
NOT-MEASURED, 0 UNRUN (`pnpm lint` recorded outside the derivation).
Four first answered a container prerequisite and were rerun green:
`check-plugin-teardown-shape --self-test` exit 3 (after `git fetch
--depth=1` of its fixture commit), `check:dts-closure` exit 1 (a dist
mid-rebuild by the concurrent dogfood closure build; 225/225 declaration
files on rerun), `check:type-check-debt` exit 3 (verify-lock queue
timeout behind the dogfood run; rerun under the lock),
`check:dual-build-cjs-loads` exit 3 (seven unbuilt packages; rerun after
the full build). CI families: this PR's check-runs.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic
(no `packages/spec` hunk).
- [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: n/a, untouched.
- [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 (the maintainer brief
is Chinese by the repo's rule).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbWsjv939FeRpCY83MV)_
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 772b356 commit 85ea224
4 files changed
Lines changed: 321 additions & 11 deletions
File tree
- .changeset
- packages
- objectql/src/validation
- rest/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 | + | |
| 18 | + | |
| 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 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
886 | 887 | | |
887 | 888 | | |
888 | 889 | | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
893 | 895 | | |
894 | 896 | | |
895 | 897 | | |
896 | 898 | | |
897 | 899 | | |
898 | | - | |
| 900 | + | |
899 | 901 | | |
900 | 902 | | |
901 | 903 | | |
| |||
969 | 971 | | |
970 | 972 | | |
971 | 973 | | |
972 | | - | |
973 | | - | |
| 974 | + | |
| 975 | + | |
974 | 976 | | |
975 | 977 | | |
976 | 978 | | |
| |||
1328 | 1330 | | |
1329 | 1331 | | |
1330 | 1332 | | |
1331 | | - | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1332 | 1342 | | |
1333 | 1343 | | |
1334 | | - | |
| 1344 | + | |
1335 | 1345 | | |
1336 | 1346 | | |
1337 | 1347 | | |
| |||
0 commit comments