Skip to content

Commit ddbd557

Browse files
committed
docs: ledger note and docblock name the 422 entry as the only carrier; changeset follows the save-door-only contract
Claude-Session: https://claude.ai/code/session_01L9qibzQhDYnejPUPpyJvyc Co-authored-by: Claude <noreply@anthropic.com>
1 parent 53c0af5 commit ddbd557

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎.changeset/36594-metadata-issue-params.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
'@objectstack/spec': patch
44
---
55

6-
fix(metadata-protocol): a `422 INVALID_METADATA` issue entry carries its zod issue's `params`, so a client of the save door can read the registered refusal code
6+
fix(metadata-protocol): a `422 INVALID_METADATA` issue entry carries the registered refusal on `params`, so a client of the save door can read the code
77

88
Clause-②: yes (widening)
99
Metadata-protocol: none
1010

11-
A spec rule that owns a registered error code stamps it on its zod issue as `params.code`, next to the fields that say which fix applies: `CONTROLLED_BY_PARENT_MASTER_INVALID` with `shape`, `PLUGIN_UI_REQUIRED_KEY_MISSING` with `key`. zod reports every such rule with its own issue code `'custom'`. The metadata save door's `422 INVALID_METADATA` built each `issues[]` entry from `path`, `message` and that `'custom'` only, so a client of the door (anything that does not parse locally the way Studio does) could not tell which rule refused the body except by its English message.
11+
A spec rule that owns a registered error code stamps it on its zod issue as `params.code`, next to the fields that say which fix applies: `CONTROLLED_BY_PARENT_MASTER_INVALID` with `shape` (an object save), and `PLUGIN_UI_REQUIRED_KEY_MISSING` with `key` (`PluginSchema`, which no save-door type parses today). zod reports every such rule with its own issue code `'custom'`. The metadata save door's `422 INVALID_METADATA` built each `issues[]` entry from `path`, `message` and that `'custom'` only, so a client of the door (anything that does not parse locally the way Studio does) could not tell which rule refused the body except by its English message.
1212

13-
- **`@objectstack/metadata-protocol`.** `MetadataIssueEntry` gains an optional `params` member: a copy of the zod issue's own `params`, present only when the issue has them. `zodIssuesToMetadataIssues` fills it, so every producer that maps through it carries it: the save door's 422, the package commit and client failure paths, and the read-path diagnostics. An object save refused for a `controlled_by_parent` master now answers `{ path: 'fields', code: 'custom', message, params: { code: 'CONTROLLED_BY_PARENT_MASTER_INVALID', shape: 'master-not-writable' } }`. Read the registered code from `params.code`.
13+
- **`@objectstack/metadata-protocol`.** The save door's 422 entry gains an optional `params` member: the registered refusal the issue carries, present only when the issue's `params.code` is a registered error code, and holding only its string, finite-number and boolean members. An object save refused for a `controlled_by_parent` master now answers `{ path: 'fields', code: 'custom', message, params: { code: 'CONTROLLED_BY_PARENT_MASTER_INVALID', shape: 'master-not-writable' } }`. Read the registered code from `params.code`. `zodIssuesToMetadataIssues` takes a new option, `refusalParams`, which only the save door sets. The read path's `_diagnostics.errors[]` and the seed refusal's `seedApplied.issues[]` keep exactly `path`, `message` and `code`, the shape their spec schemas publish.
1414
- **`@objectstack/spec`.** The `CONTROLLED_BY_PARENT_MASTER_INVALID` docblock and its ledger note now say the save door's 422 carries the code on `params.code`.
1515

16-
Nothing to migrate. The entry's `code` is unchanged (still zod's issue code, `'custom'` for these rules), and an issue without `params` gets no `params` member, so a client that matches `code` or compares whole entries for other issues reads exactly what it read before.
16+
Nothing to migrate. The entry's `code` is unchanged (still zod's issue code, `'custom'` for these rules), and an entry that carries no registered refusal gets no `params` member, so a client that matches `code` or compares whole entries for other issues reads exactly what it read before.

‎packages/spec/src/api/error-code-ledger.zod.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,18 +1953,20 @@ export const ERROR_CODE_LEDGER = {
19531953
// tree answers with it, the thrown value is the boundary.
19541954
'CONNECTOR_UPSTREAM_CHANGED',
19551955
'CONNECTOR_UPSTREAM_UNAVAILABLE',
1956-
// `door: 'none'` on the `PLUGIN_UI_REQUIRED_KEY_MISSING` reading below: the
1956+
// `door: 'none'` on the `PLUGIN_UI_REQUIRED_KEY_MISSING` reading below, read
1957+
// as: no door answers with this code as its `error.code`. The
19571958
// `controlled_by_parent` master refusal's code (`data/controlled-by-parent-master.ts`),
19581959
// stamped on the zod ISSUE as `params.code` beside `params.shape` by
19591960
// `ObjectSchema`'s refinement and `defineStack`'s extension-merge gate, never
19601961
// on a thrown error, and not in the `message`; no `status` of its own.
19611962
// Visible on the zod issue itself (any `safeParse`, the Studio settings
19621963
// tab's path, which keys its localized wording on it), on `defineStack`'s
19631964
// `STACK_SCHEMA_INVALID` refusal, whose `issues` are the raw zod issues, and
1964-
// on the metadata save door's `422 INVALID_METADATA`: `zodIssuesToMetadataIssues`
1965-
// copies the issue's `params` onto its entry, where this code is
1966-
// `params.code` beside `params.shape`; the entry's own `code` stays zod's
1967-
// issue code ('custom').
1965+
// inside the metadata save door's `422 INVALID_METADATA` body, on an
1966+
// `issues[]` entry: `zodIssuesToMetadataIssues` carries the registered
1967+
// refusal there as `params.code` beside `params.shape`, while the body's
1968+
// `code` is `INVALID_METADATA` and the entry's own `code` stays zod's issue
1969+
// code ('custom'). The read path's `_diagnostics.errors[]` does not carry it.
19681970
'CONTROLLED_BY_PARENT_MASTER_INVALID',
19691971
'EXTERNAL_SCHEMA_MISMATCH',
19701972
'EXTERNAL_SCHEMA_MODE_VIOLATION',

‎packages/spec/src/data/controlled-by-parent-master.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ export type ControlledByParentMasterShape =
120120
* `STACK_SCHEMA_INVALID` refusal, whose `issues` are the raw zod issues, and on
121121
* the metadata save door's `422 INVALID_METADATA`, whose `issues[]` entries
122122
* (`zodIssuesToMetadataIssues`, `@objectstack/metadata-protocol`) carry the
123-
* issue's `params` beside `path`, `message` and zod's own issue `code`
124-
* (`'custom'`): read the code there from `params.code`.
123+
* registered refusal on `params` beside `path`, `message` and zod's own issue
124+
* `code` (`'custom'`): read the code there from `params.code`. Where it is not:
125+
* the read path's `_diagnostics.errors[]`, whose entries are exactly `path`,
126+
* `message` and `code`.
125127
*/
126128
export const CONTROLLED_BY_PARENT_MASTER_INVALID = 'CONTROLLED_BY_PARENT_MASTER_INVALID' as const;
127129

0 commit comments

Comments
 (0)