You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b3d7a70
Browse filesBrowse the repository at this point in the historyBrowse files
fix(spec): ObjectSchema.fields refuses constructor / prototype at the offending key, not at the fields slot (#21070)
Closes#20997
Clause-②: no (no key is added and the accept set does not move: only the
issue path of an existing refusal changes, read against
`scripts/pm/clause2-line.mjs`)
## What changes
`ObjectSchema.fields` still refuses a field named `constructor` or
`prototype`. The issue is now reported at the key (`fields.constructor`,
`fields.prototype`) instead of at `fields`, as `__proto__` and the key
grammar's `invalid_key` already were. A document with both names gets
two issues instead of one. The issue code (`custom`) and the message are
unchanged.
## How
One `.refine(bannedKeys([name]), { path: [name] })` per reserved name
replaces the single two-name refine. A `.superRefine()` with a computed
path was not used: it has no readable predicate, so the published JSON
Schema would lose the ban (#19346). The published `fields` node now
carries one `propertyNames` clause per name in the same `allOf`.
`bannedKeys` (`shared/refinement-projection.ts`) is not edited. Its
other caller, `system/tracing.zod.ts` (`bannedKeys(['dialect'])`,
`abort: true`), keeps its slot-level refusal on purpose, as its own
comment says. `record-proto-key-guard.ts` changes only in its docblock.
## Tests
In `object.test.ts`:
- each name is refused at `fields.NAME`, with no slot-level issue left;
- both names give two issues;
- a `Bad Name` control;
- the published-node and census pins are updated.
The local runs and ablations are in the `os-dev-report` on #20997.
`dispatch-gates.mjs --commands` was not run locally, so CI on this head
is the measurement.
The consumer half is objectui#11302 (the designer page that drops the
issue detail). It is not addressed here.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Sfe5YjBLwB9J3y8fvm2xq1)_
Co-authored-by: Claude <noreply@anthropic.com>
fix(spec): `ObjectSchema.fields` refuses `constructor` and `prototype` at the offending key (`fields.constructor`, `fields.prototype`), not at the `fields` slot
6
+
7
+
Clause-②: no
8
+
9
+
A field map carrying a key named `constructor` or `prototype` is refused, as before. The
10
+
refusal used to be reported at the path `fields`, which names no field, so a form reading the
11
+
structured issues of a refused save could not point at the field that caused it. It is now
12
+
reported at that key, like the `__proto__` refusal (`fields.__proto__`) and the key grammar's
13
+
`invalid_key` refusal (`fields.Bad Name`) already are. A document carrying both names gets two
14
+
issues, one at each key, where it used to get one at the slot.
15
+
16
+
Nothing else moves. The same keys are refused and the same documents are accepted. The issue
17
+
code (`custom`) and the message are unchanged. The published JSON Schema states the same ban:
18
+
it is now written as one `propertyNames` clause per name inside `allOf` instead of one clause
19
+
naming both, which accepts and refuses exactly the same documents.
0 commit comments