Commit 50185a8
A script/cross_field/conditional validation whose CEL predicate could not be
evaluated was logged at WARN and SKIPPED, so the write went through. The rule
stayed declared, listed in the metadata, and enforced nothing — on exactly the
records whose shape triggered the fault. For a validation that inverts the
guarantee: the rule exists to reject a write.
Two halves, neither sufficient alone:
1. The record a predicate reads is TOTAL over the object's declared fields on
UPDATE as well as insert — `null` when the key is in neither the payload nor
the prior record — and the `previous` binding is materialised the same way.
Without this, step 2 would 422 every legitimate predicate on any driver that
stores only written columns (the shape hotcrm#630 reported). Materialisation
covers DECLARED fields only, so a typo'd key stays unevaluable and reportable.
2. A predicate that still faults REJECTS the write, naming the rule and the
offending key. `severity` still governs blocking, so an advisory rule stays
advisory.
A `conditional` now counts as needing the prior record whenever it declares a
`when`: that predicate is evaluated against the merged record, so without the
prior state it read a PATCH as though it were the whole record.
Fail-closed evaluation immediately found two of our own example rules that had
never enforced anything: `has(x)` is TRUE for a declared column holding NULL, so
`has(a) && has(b) && a < b` faults on `null < null` on any driver that returns
its NULL columns. Both are rewritten with `!= null` guards, and the rejection
message now teaches that distinction.
Claude-Session: https://claude.ai/code/session_015Br2xsJsczFsTR9bvbh2Ny
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 891d345 commit 50185a8
6 files changed
Lines changed: 712 additions & 41 deletions
File tree
- .changeset
- examples
- app-crm/src/objects
- app-showcase/src/data/objects
- packages/objectql/src/validation
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
| |||
0 commit comments