Skip to content

Commit 277bda5

Browse files
committed
docs: error-handling, error-catalog and cli pages teach the optional controlled_by_parent master
A controlled_by_parent object may declare its only master_detail with required: false (ADR-0055 §1 as amended). A stored empty reference on it is not a 422: the row is its owner's, read by the owner and View All on the detail and written by the owner and Modify All. The 422 MISSING_REQUIRED_FIELD exception now names a required master only; the declaration table gains the optional-master row; the v18 refused-shape list no longer lists an explicit required: false; and --parent-write-reach names the null-master records it proves. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2ebbZkr2QAEG1x7UC8
1 parent af3451b commit 277bda5

3 files changed

Lines changed: 108 additions & 64 deletions

File tree

‎content/docs/api/error-catalog.mdx‎

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,38 @@ substitute. See the [Data API](/docs/api/data-api).
181181
### `MISSING_REQUIRED_FIELD`
182182
**Cause:** A required field was not provided in the request body.
183183
**Fix:** Include the missing field. Check `fields` for the field name — **except** on the
184-
`controlled_by_parent` stored-master path below, where the status is `422` and no `fields`
184+
`controlled_by_parent` stored required-master path below, where the status is `422` and no `fields`
185185
array is sent; read the field name out of the message there.
186186
**Retry:** `no_retry`
187187

188188
<Callout type="warn">
189189
**`MISSING_REQUIRED_FIELD` is `400` with one exception: a `controlled_by_parent` detail
190-
whose stored master reference is null answers `422`, without `fields`.**
190+
whose stored reference to a required master is null answers `422`, without `fields`.**
191191

192192
An object whose `sharingModel` is `controlled_by_parent` derives its access from a master
193193
record, so the gate authorizing writes to it resolves that master *before* the executor —
194194
and the executor is where required-field validation runs. An update or delete **by id** of
195-
a detail record whose *stored* master reference is null answers
196-
`422 MISSING_REQUIRED_FIELD`, whatever the declaration: the caller sent no such field, so
197-
nothing could be named in `fields` and no payload would fix it.
195+
a detail record whose *stored* master reference is null, where the master is declared
196+
`required: true`, answers `422 MISSING_REQUIRED_FIELD`, whether or not the master is marked
197+
`readonly` or `system`: the caller sent no such field, so nothing could be named in `fields`
198+
and no payload would fix it.
199+
200+
An optional master never answers this code. When the object's only `master_detail` is
201+
declared `required: false` (an optional master, ADR-0055 §1 as amended), a stored empty
202+
reference is not an error: the row belongs to no master and is its owner's. Its owner and a
203+
holder of View All on the detail read it; its owner and a holder of Modify All on the detail
204+
update or delete it, and anyone else is refused `403 PERMISSION_DENIED`.
198205

199206
A request that leaves the master reference out, or empties it, does not answer this code.
200-
On a `master_detail` that is `required` and neither `readonly` nor `system`, validation
201-
answers it with the documented `400 VALIDATION_FAILED` and `fields`. A master reference
202-
marked `readonly` or `system` is not one an author's write supplies, so it cannot be the
203-
master (ADR-0055 §1): `ObjectSchema` refuses that declaration at parse
204-
(`master-not-writable`), and on an object that reaches the runtime without the parse, every
205-
write that sets the reference answers `422 INVALID_METADATA`:
207+
On a `master_detail` that is `required: true` and neither `readonly` nor `system`, validation
208+
answers it with the documented `400 VALIDATION_FAILED` and `fields`. On an optional master
209+
nothing refuses it: an insert that names no master is admitted and its creator owns the row,
210+
and an update that empties the reference asks edit access on the master it leaves
211+
(`403 PERMISSION_DENIED` without it). A master reference marked `readonly` or `system`,
212+
required or optional, is not one an author's write supplies, so it cannot be the master
213+
(ADR-0055 §1): `ObjectSchema` refuses that declaration at parse (`master-not-writable`), and
214+
on an object that reaches the runtime without the parse, every write that sets the
215+
reference answers `422 INVALID_METADATA`:
206216

207217
- every insert, single or batch, whether or not it names a master;
208218
- every update whose body carries the reference key, whatever the value, `null` included.
@@ -211,19 +221,24 @@ Its message starts `[Security] Configuration defect:` and carries the parse's ow
211221
naming the object, the field, the flag and the fix. A delete, and an update that leaves the
212222
key out, are answered as on any detail.
213223

214-
A `master_detail` with no `required`, and a `required` `lookup` on an object that declares no
215-
`master_detail`, are not master references at all: the master is exactly one `master_detail`
216-
declared `required: true` (ADR-0055 §1). `ObjectSchema` refuses such an object at parse, and
217-
one that reaches the runtime unparsed answers every write `422 INVALID_METADATA`.
224+
The master is exactly one `master_detail`: the one declared `required: true`, or, when the
225+
object declares none, its only `master_detail` declared `required: false` (ADR-0055 §1 as
226+
amended). Two `master_detail` fields with none required, two required ones, and a
227+
`required` `lookup` on an object that declares no `master_detail` name no master at all:
228+
`ObjectSchema` refuses such an object at parse, and one that reaches the runtime unparsed
229+
answers every write `422 INVALID_METADATA`. Write `required` on the master either way:
230+
`ObjectSchema.create()` forces an omitted one to `true` and `os lint` reports the omission
231+
at `error`, while a raw parse reads it as `false`, the optional master.
218232

219233
The full matrix is on the protocol page:
220234
[`MISSING_REQUIRED_FIELD`](/docs/protocol/kernel/error-handling#missing_required_field).
221235

222236
The `INVALID_METADATA` refusal is not going to be relaxed: required-field validation skips
223237
`system` and `readonly` fields before its required check, so on those two declarations the
224-
gate is the only thing standing between the request and a detail record outside its master
225-
— which the `controlled_by_parent` read filter (`fk IN (readable masters)`) can never match,
226-
leaving a record readable by nobody.
238+
gate is the only thing standing between the request and, under a required master, a detail
239+
record outside its master — which the read filter of a required master
240+
(`fk IN (readable masters)`, with no arm for an empty reference) can never match, leaving a
241+
record readable by nobody.
227242

228243
**Branch on `code`, treat `fields` as optional, and read the status off the response**
229244
rather than deriving it from the table at the end of this page.
@@ -1011,7 +1026,7 @@ async function handleApiCall() {
10111026
| 404 | `not_found` | `RECORD_NOT_FOUND`, `OBJECT_NOT_FOUND`, `ENDPOINT_NOT_FOUND` |
10121027
| 409 | `conflict` | `CONCURRENT_MODIFICATION`, `UNIQUE_VIOLATION`, `DELETE_RESTRICTED` |
10131028
| 413 | `validation` | `PAYLOAD_TOO_LARGE` — an upload over the storage settings' `max_upload_mb`, or an import over its row ceiling (see [above](#payload_too_large)) |
1014-
| 422 | `validation` | `MISSING_REQUIRED_FIELD` on a `controlled_by_parent` detail whose stored master reference is null (see [above](#missing_required_field)) — this row is an exception to the 400 row, not a second home for the code |
1029+
| 422 | `validation` | `MISSING_REQUIRED_FIELD` on a `controlled_by_parent` detail whose stored reference to a required master is null; an optional master's empty reference is not an error (see [above](#missing_required_field)) — this row is an exception to the 400 row, not a second home for the code |
10151030
| 429 | `rate_limit` | `RATE_LIMIT_EXCEEDED`, `QUOTA_EXCEEDED` |
10161031
| 500 | `server` | `INTERNAL_ERROR`, `DATABASE_ERROR` |
10171032
| 501 | `server` | `NOT_IMPLEMENTED` — the storage routes answer it when the adapter cannot issue presigned URLs |

‎content/docs/deployment/cli.mdx‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ can produce, because both supply a live one.
21392139
| Types with no repository write path (`agent`) | Their write path records no history and would force a draft live — a half-write is worse than leaving the row to the read path |
21402140
| Rows that still fail the current schema after conversion | That is a genuine contract violation, not chain-owned history. The write path's rejection is correct; fix the row in Studio |
21412141
| A site the conversion chain leaves as stored because no lossless rewrite exists — above all a page filter carrying `$and` / `$or` / `$not` | Flattening a combinator changes which rows the page selects, so it is never done. Each site is printed as a `TODO` line under its row — path, block, and what blocks the rewrite — whatever the row's outcome; a row with nothing but TODOs is reported `skipped`. It does not fail the run, since no run of this pass can clear it: rewrite each site by hand |
2142-
| A stored shape protocol 18 refuses and no conversion rewrites — a `controlled_by_parent` object without exactly one required `master_detail` (two masters, none, a required `lookup` only, an explicit `required: false`), a view bound to the retired view-level API data source or a page component whose `data` prop binds it (`object-grid`, `object-map`, `object-gantt`, `object-tree`), a flow value slot carrying a `{…}` token (a `get_record` / `update_record` / `delete_record` filter operand among them) | Each would need a choice only its owner can make — which master, which page, what an absent value should do — so it is never rewritten. Each site is printed as a `TODO` line under its row, naming the step-18 entry that refuses it, the object, view, page component or flow node, and the owner's choices; a binding's request headers are withheld. Until it is rewritten by hand, the row is refused: an object registers but derives no master, a view registers under `[metadata_spec_invalid]`, a page still loads, its next save is refused at the metadata save door (422), and `os validate`, `os build` and `os lint` refuse the binding in source, and a flow is not registered |
2142+
| A stored shape protocol 18 refuses and no conversion rewrites — a `controlled_by_parent` object without exactly one master, which is one `master_detail` declared `required: true` or, with none, its only `master_detail` declared `required: false` (two masters, none, a required `lookup` only; an explicit `required: false` on the only `master_detail` is that optional master, admitted by `cbp-optional-master-admitted` and not listed), a view bound to the retired view-level API data source or a page component whose `data` prop binds it (`object-grid`, `object-map`, `object-gantt`, `object-tree`), a flow value slot carrying a `{…}` token (a `get_record` / `update_record` / `delete_record` filter operand among them) | Each would need a choice only its owner can make — which master, which page, what an absent value should do — so it is never rewritten. Each site is printed as a `TODO` line under its row, naming the step-18 entry that refuses it, the object, view, page component or flow node, and the owner's choices; a binding's request headers are withheld. Until it is rewritten by hand, the row is refused: an object registers but derives no master, a view registers under `[metadata_spec_invalid]`, a page still loads, its next save is refused at the metadata save door (422), and `os validate`, `os build` and `os lint` refuse the binding in source, and a flow is not registered |
21432143
| Any other site `registerFlow` refuses in a stored flow the parse accepts — a text slot's template hole, a decision's `mode`, a malformed predicate, a plugin node's undeclared config key, an `api` flow with no secret | The flow's own definition is wrong, and no conversion rewrites it. Each site is printed as a `TODO registerFlow` line under its row, in the words `registerFlow` refuses it with; a site already listed under a step-18 entry is not repeated. Until it is fixed, the flow is not registered at boot and never runs. A flow the parse itself refuses is reported among the rows that could not be rewritten, in the parse's words |
21442144
21452145
**One thing it lists and never writes: decision nodes that changed meaning at
@@ -2706,10 +2706,11 @@ os verify --dashboard-windows # Also prove each dashboard date
27062706
reported inconclusive, never proven.
27072707
With `--parent-write-reach`, another fresh boot proves ADR-0055's write rule
27082708
for every object declared `controlled_by_parent` (exactly one
2709-
`master_detail` field names its master): editing, deleting or creating a
2710-
detail is admitted exactly when the caller holds that verb on the detail's
2711-
object **and** can edit its master. The first half is read from the
2712-
server's effective permissions for the caller (`/auth/me/permissions`); the
2709+
`master_detail` field names its master, required or optional): editing,
2710+
deleting or creating a detail is admitted exactly when the caller holds
2711+
that verb on the detail's object **and** can edit its master. The first
2712+
half is read from the server's effective permissions for the caller
2713+
(`/auth/me/permissions`); the
27132714
second is measured, by an empty update of the master as the caller, which
27142715
runs every write gate the master has — for a master that is itself
27152716
controlled by its parent, the gate above it too. The writes go through the
@@ -2726,9 +2727,15 @@ os verify --dashboard-windows # Also prove each dashboard date
27262727
answer disagrees fails the run, and so does a persona that could not be
27272728
provisioned; a refusal that is not the platform's `403 PERMISSION_DENIED`
27282729
naming the detail and the operation (a rule, a hook's own code, a refusal
2729-
on another object) is reported inconclusive, never proven. An object
2730-
with two `master_detail` fields, none, or a chain at the write gate's depth
2731-
bound is reported `excluded`. A detail two levels below its root master (a
2730+
on another object) is reported inconclusive, never proven. For an optional
2731+
master (its only `master_detail` declared `required: false`) the run also
2732+
proves the records that name no master: such a record is its owner's, so
2733+
its edit or delete is admitted exactly when the caller holds that verb on
2734+
the detail's object **and** owns the record (`owner_id`) or holds Modify All
2735+
on that object, and a create that names no master exactly when the caller
2736+
holds create on it; a null-master record the persona cannot read is not
2737+
probed. An object with two `master_detail` fields, none, or a chain at the
2738+
write gate's depth bound is reported `excluded`. A detail two levels below its root master (a
27322739
line under a quote under an account) is answered the same way: its write is
27332740
admitted exactly when the caller holds the verb on the detail and may update
27342741
the middle master directly, which also needs edit access to the root, and

0 commit comments

Comments
 (0)