Skip to content

Commit 49c09ed

Browse files
feat(objectql): a validation rule's refusal fills its message's {{ }} holes with the judged record's values (#38736)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9SNzk6FfxPPrxLwCB5BftuN)_ Part of #37909 — PR 2 of the ruling's sequencing (`domain:server`: render in `authoredRuleMessage`, currency and readable-field handover, the empty-on-unreadable pins). PR 1 (#38687, spec + lint, merged as 9cbb41b) is the doors; PR 3 (skills and docs) stays on the card. Clause-②: yes (widening) Metadata-protocol: semantic Skills-docs: follow-up #37909 (PR 3 of the ruling's sequencing: skills and docs) ## 维护者速读 - 用户能看到什么变化:校验规则拦下保存时,提示语里的 `{{ record.字段 }}` 会填上被拦记录的真实值(比如「总价 ¥1,200.00 低于已收 ¥1,500.00」),金额按组织默认币种、按用户语言格式化;看不到或被遮罩的字段一律留空。系统身份替某人执行的写(如该人触发的系统流程)按该人的权限判定,没有安全服务时全部留空并记日志。 - 为什么做:维护者已裁(P3);这是第二步,让第一步定下的写法真正生效,HotCRM 的改单拦截才能说出差多少钱。 - 出错会怎样:最坏是某个洞该显示的值显示成空;规则拦不拦不受影响,值也不会写进错误的其它字段;撤回这次合并即回到「原样显示」。 - 要你做什么:组织没设默认币种时,提示语里不带币种的金额占位怎么处理,正等你在决策卡上定;本 PR 暂按席位推荐的 A(该占位留空、日志提醒设置默认币种)实现,你选别的方案只改一个函数,改完再请你审批。 ## What changes Ruling P3 (card comment 7239726323), parameters 5–8, and the forward flags of PR 1's contract review (7269393846). - **`@objectstack/objectql`** — `authoredRuleMessage` (`validation/rule-validator.ts`) now fills the sentence it picks: - translation first (parameter 7): the translated template is picked and filled; if it does not render, the authored template is filled instead and the write's logger names the translation (`objects.O._validations.R.message`, the locale); an authored message that does not render (one stored before the doors) is shown as written and the logger names the rule; - the fill is `renderRuleMessage` (new `validation/rule-message-render.ts`) through the formula `templateEngine` — no second engine — over the merged record (`record`) and the stored row (`previous`, `null` on an insert), in the refusal's negotiated locale, with the tenant default currency and the reference timezone. Every rule kind that emits an authored message fills it: `script` / `cross_field`, `format`, `json_schema`, `state_machine`, and a `conditional` branch. A `script` rule's holes read the record as judged before related rows are hydrated into reference fields, so `{{ record.account }}` is the stored id, never the related row; - what a hole may show (parameter 6) is `ValidationMessageContext.rendering`, computed once per write by the new `engine-rule-message-rendering.ts` (`attachRuleMessageRendering`), called beside `validationMessageContext` on the three paths that build it: `engine-insert.ts`, `engine-update.ts` (the by-id and bulk legs share it) and `engine-validate.ts` (the dry run). It is computed only when the object's rule messages or their translations carry a `{{`, so no other write asks the security service anything new. - **The showable fields** — `getReadableFields` ∩ `getQueryableFields` of the registered security service (the contract: "the difference between the two is exactly the fields this caller sees masked"); with no `getQueryableFields`, or `undefined` from it, every `maskingRule` field counts as masked (the contract's prescribed fallback). Every field the engine masks or omits on a read (`secret`, generic `password`, `internal`) is never showable. A hole is empty twice over: blanked before the render, and absent from the scope the engine evaluates. - **Whose read (contract review M1, fix (a))** — both projections are asked under the write's own context, except on an elevated write (`isSystem`) that names a person (`userId`): a `runAs: 'system'` flow, an action body (`{ ...caller, isSystem: true }`), the approvals mirror. There they are asked for that person: the same context with `isSystem: false`, carrying the positions and permission sets it carries, or, where it carries none (the flow's and the approvals mirror's context), the person's own grants resolved through `resolveUserAuthzGrants` (`@objectstack/core`), as a `runAs: 'user'` hook fired by the same write seeds them. Grants that cannot be read: every hole empty. A user-less system write (a schedule, a platform sweep) keeps the system's answer; its sentence reaches the server log alone. - **Fail closed, and say why (S1)** — no security service registered (the kernel throws on an unregistered name; a bare engine's slot is empty), a service that cannot be asked (no function in the slot, no `getReadableFields`), one that answers `undefined` or throws, and unreadable grants of the person an elevated write was made for: nothing is showable, every hole renders empty, and the write's logger gets one line naming the cause (`RuleMessageRendering.unanswered`), once per write. - **What the log is told (S2)** — a hole no reader could ever see filled (another root, a bare root, a read through a field, a field the object does not declare: a message stored before the doors) is named with its rule and the hole. A hole empty only for this reader (unreadable, masked) is never logged. Each distinct line is written once per write, so a bulk refusal does not repeat it (N1). - **The currency** (parameter 5) — the write's `ExecutionContext.currency` (the organization's `localization.currency`, which the request context already resolves), when it is a three-capital ISO 4217 code. **Pending the maintainer's ruling (parameter 8 fork, put to the maintainer as a decision card by the seat):** with no tenant default, a `currency` hole with no argument passes the doors but cannot render. Provisionally (option A, the seat's recommendation) that hole renders empty and the write's logger names the rule, the hole and the setting, saying the organization has none set or the write carried none (N1) (Setup → Localization, `localization.currency`); the rest of the sentence renders. It is isolated in one function, `tenantCurrencyHole` (`validation/rule-message-render.ts`), and pinned by one test; a different ruling changes those two and the changeset's sentence, nothing else. ⛔ The amount is never formatted in a currency nobody chose, nor shown unformatted. - **`@objectstack/spec` + `@objectstack/lint`** — the roots export is renamed before its first release, `VALIDATION_MESSAGE_TEMPLATE_ROOTS` → `VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS` (contract review N2: `@objectstack/spec/system` already has a `VALIDATION_MESSAGE_*` field-constraint family that binds no roots), with its lint importer, the translation describe that names it, and the regenerated `api-surface/data.json`, `export-origins/data.json` and `docs/references/system/translation.md`. PR 1's changeset is edited to name the final export (both ship in one release). ### Decisions this PR takes - **N5, `previous.FIELD` on an insert-only rule:** the doors keep accepting it and it renders empty, as on every insert (parameter 1 allows it; a rule with `events: ['insert', 'update']` reads it on one leg only). Pinned. - **A hole over a root other than `record` / `previous`, a bare root, a read through a field, an undeclared field:** the doors refuse each (PR 1); a rule stored before them renders each empty, never the built-in sentence's own parameters. ### Deliberate correction of a pending release note `.changeset/37909-rule-message-template-holes.md` (PR 1's, pending, not yet released) is edited in one sentence: its **Exports** bullet named `VALIDATION_MESSAGE_TEMPLATE_ROOTS`, which this PR renames, so it now reads "`@objectstack/spec/data` gains `VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS` (`['record', 'previous']`)". Restoring it would publish a release note naming an export the release does not carry. `check-empty-changeset` stays red on that file by design; the dispatching seat confirms the correction by its own record. ### Outside the claimed file surface - `packages/services/service-automation/src/flow-rule-message-reader.integration.test.ts` (new, test only): contract review M1 asks for the flow path pinned end to end (`runAs: 'system'` → `innerRefusal`), which only a test composing the automation engine reaches. No service-automation source changes. - `content/docs/permissions/system-context.mdx` (one register row, 29g, and the regenerated register): the new `readerContext` reads `isSystem` to de-elevate, and `pnpm check:system-context-census` requires every such read to be owned by a row naming its symbol. ### Tests forced to change - `packages/objectql/src/validation/rule-validator.state-machine-option-labels.test.ts` — "leaves an author-written message exactly as written — no holes are filled in it" pinned the contract this card changes (ruling P3). Its intent stays: the built-in sentence's `{{from}}` / `{{to}}` never fill an authored message. Those are holes over another root, so they now render empty; the code and `constraint` assertions are unchanged. ## Tests - `packages/objectql/src/validation/rule-message-render.test.ts` (19, through `evaluateValidationRules`): formatters and locale, the tenant currency, `previous` on update and on insert, plain text and a single brace as written; the field floor (outside `showable`, never logged; no rendering at all; read-through / bare root / other root / undeclared, each logged with its rule; the stored id of a hydrated reference; no value in the machine fields); the scope floor on its own, a hole the blanking builds (N5); an unanswered field security, its cause logged; every rule kind (`conditional` branch, `format`, `state_machine`); translation first, its fallback with the warning, a pre-door authored message as written; and the provisional no-currency arm (that hole empty, the rest rendered, the rule and the setting named). - `packages/objectql/src/engine-rule-message-rendering.test.ts` (15, a real engine with the security service as a double in its source slot): readable and unmasked shows, masked / `password` / `internal` empty; unreadable empty; no `getQueryableFields` → `maskingRule` empty; a lifted mask shows; `undefined`, a throw from either projection, a throwing source, a service without `getReadableFields` → every hole empty, the write still refused, one log line naming each cause; no service registered → every hole empty and the line; a reader-only blank never logged; stored structural holes logged once per write across a bulk insert. Elevated writes (M1): `{ ...caller, isSystem: true }` asked for the caller with their sets, never as the system; `{ isSystem: true, userId }` with no sets on an engine with no permission store → grants unreadable, every hole empty, the cause logged; CONTROL a user-less system write keeps the system answer; CONTROL the same person's own write reads the same. `| currency` in the context's currency and locale; `previous` on a real update; the dry run fills the same sentence. - `packages/services/service-automation/src/flow-rule-message-reader.integration.test.ts` (4, ObjectKernel + ObjectQLPlugin + driver-sql on better-sqlite3 + identity objects + the real SecurityPlugin + the real AutomationEngine): a member profile withholds `margin`; a `runAs: 'system'` flow started by that member, refused by the rule, carries `Amount -1 is below the margin on Acme.` in `innerRefusal.message` (run against the previous head's build it carried `… the margin 30 …`); `runAs: 'user'` and the member's own request read the same; CONTROL a user-less system write shows `30`. - Ablations: dropping the masked-field judgement reds 2 engine tests; building the scope from the whole row instead of the showable values reds the N5 pin (`SSN 123-45-6789 end`). ## Acceptance notes - The render ships in the same release as PR 1 (#38687, merged): PR 1 alone teaches holes that render as written. This branch was restarted from `main` after PR 1 merged and its four commits rebased onto it. - The rendered sentence is written to the server log by the engine's existing `Insert operation failed` warning, as the authored message was; it carries only fields the person the refusal is worded for may read. - Out of scope, from contract review 7273883345: N2 (an `Intl` `RangeError` for a locale tag or time zone `Intl` does not know shows the template as written; whether such a tag reaches a write's context is not established), N3 (`objectstack validate`'s seed-row refusal, `packages/lint/src/seed-row-refusals.ts`, now prints blank holes; a follow-up hands it a `rendering` over the seed row's declared fields, or prints the template), N7 (the projections are asked on every write to an object whose messages carry a hole, refused or not; asking at the first refusal needs an async render). Each goes to PR 3 or a follow-up card, as the seat files it. ## Verification - `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/validation/rule-message-render.test.ts src/engine-rule-message-rendering.test.ts`: 34 passed; `pnpm --filter @objectstack/service-automation exec vitest run src/flow-rule-message-reader.integration.test.ts`: 4 passed. - Two-minute check: in `examples/app-showcase`, give a validation rule the message `Total {{ record.total_price | currency }} is too low.`, set Setup → Localization → Default currency, and save a record the rule refuses: the refusal names the amount. <details><summary>Local gates at head 331b47d</summary> - `node scripts/pm/dispatch-gates.mjs --commands` (derived after the last commit): 125 commands, each run with stdin closed through the verify lock; 124 `exit 0`, and `node scripts/check-empty-changeset.mjs --base origin/main :: exit 1`, the deliberate correction above. `--ran` reconciliation: 125 derived, 125 run, 0 NOT-MEASURED, 0 UNRUN. - The run at 8f25796 (104 derived) had one other red, `pnpm check:system-context-census` (the `readerContext` read had no owning row); 331b47d adds row 29g and the census passes in the 125. - `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2` on the tree committed as 6a49759 + 8f25796: 643 files, 14602 tests, all passed (lock VERDICT command-exit 0). - Dogfood battery (`pnpm --filter @objectstack/dogfood test`) at 331b47d: lock VERDICT command-exit 0; Test Files 495 passed, 3 skipped; Tests 4187 passed, 68 skipped; no failure. - `pnpm build --concurrency=2` (whole workspace) on the rebased head 9b716a3: lock VERDICT command-exit 0; `@objectstack/objectql` rebuilt at the fix (exit 0) before the service-automation test ran against it. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmQ6vV3YvhJWKF1gSDs --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 111ad63 commit 49c09ed

20 files changed

Lines changed: 1342 additions & 41 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/objectql': minor
3+
'@objectstack/spec': minor
4+
'@objectstack/lint': minor
5+
---
6+
7+
feat(objectql): a validation rule's refusal fills its message's `{{ }}` holes with the judged record's values
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: semantic
11+
12+
A validation rule's `message`, and the translation of it a refusal shows, is now filled when a write is refused: `{{ record.FIELD }}` shows the merged record the rule judged and `{{ previous.FIELD }}` the stored row before an update, through the template formatters (`currency`, `number`, `percent`, `date`, `datetime`, `upper`, `lower`, `trim`, `truncate`, `default`, `json`). `Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }})` now reads `Total $1,200.00 is below what was received ($1,500.00)`. Before, the sentence was returned as written, holes and all. A message with no `{{` is returned exactly as before.
13+
14+
- **What a hole may show.** A hole shows a field only when the person the refusal is worded for may read it unmasked, as the security service answers for that person. On an ordinary write that is the person who wrote. On an elevated write made for a person (a `runAs: 'system'` flow they started, whose refusal reaches them as the run's `innerRefusal`; an action body; an approval decision), the security service is asked for that person, with their own permission sets, never for the system; if their grants cannot be read, every hole renders empty. Only an elevated write that names no person (a schedule, a platform sweep) is answered as the system, and its sentence reaches the server log alone. A field the reader cannot read, a field masked for them, a `secret` / `password` or `internal` field, a field the object does not declare, a read through a field (`{{ record.account.name }}`) and a hole over any other root render empty. If no security service is registered, or the one registered cannot answer, answers nothing or fails, every hole renders empty and the server log says why, once per write. The rule's verdict never depends on the sentence, and no value is added to the error's other fields.
15+
- **Formatting.** The formatters render in the refusal's language. `| currency` with no argument formats in the organization's default currency (Setup → Localization, `localization.currency`); `| currency:EUR` names one. If no default currency reaches the write (the organization has none set, or the write carried none), a `| currency` hole with no argument renders empty, the rest of the sentence renders, and a warning in the server log names the rule and the setting to fill; the amount is never formatted in a currency nobody chose. `{{ previous.FIELD }}` renders empty on an insert.
16+
- **Translations first.** The translation for the refusal's language is filled first. A translation that does not render (one stored before `objectstack validate` judged it) is replaced by the authored message, filled, and a warning in the server log names the translation. An authored message that does not render is shown as written, as before, and the log names the rule.
17+
18+
What changes for a deployed app: a rule message that already carries a `{{ record.FIELD }}` hole shows the value from this release. A message stored before `objectstack validate` judged its holes may carry one no reader can ever see filled: a hole over another root (`{{ from }}`), a bare root (`{{ record }}`), a read through a field, or a field the object does not declare. Such a hole now renders empty where it used to be shown as written, and the server log names the rule and the hole on each write that renders it. Run `objectstack validate` and rewrite each hole it names.

‎.changeset/37909-rule-message-template-holes.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The message is now a `{{ }}` template (ADR-0032 §3) over the record the rule ju
2121

2222
Filling the holes at run time is the next change on this card; until it lands, a hole that passes the doors is returned as written.
2323

24-
- **Exports.** `@objectstack/spec/data` gains `VALIDATION_MESSAGE_TEMPLATE_ROOTS` (`['record', 'previous']`). The `message` describe of the six validation-rule variants and of the `_validations` translation entry now state the template.
24+
- **Exports.** `@objectstack/spec/data` gains `VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS` (`['record', 'previous']`). The `message` describe of the six validation-rule variants and of the `_validations` translation entry now state the template.
2525
- **The ADR-0087 ledger** gains the semantic entry `validation-rule-message-template-holes` under step 19.
2626

2727
FROM → TO:

‎content/docs/permissions/system-context.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ bugs — it is the protection or the side effect that silently does not happen.
158158
| 29d | The recycle bin's tenant wall does not apply: `restore`, `purge` and `empty` read and remove **every organization's** entries | objectql | Get: the bin's own doors reach any entry, as the system reaches every wall. Every caller that is not system is held to the Layer-0 verdict: one the wall denies (a signed-in caller with no active organization under a walled posture) sees no entry, so `restore` answers `null`, `purge` `false` and `empty` `0`, and the removal is scoped by the verdict the security layer recorded on the dispatch when it recorded one (#30237) | `recycleBinWallDenies` |
159159
| 29e | A restore of an entry someone else deleted asks **no recycle-bin grant** | objectql | Get: the system restores any entry. Every caller that is not system restores only the entries whose `deleted_by` is its own `userId` unless its effective permissions grant `manageRecycleBin` on the entry's object; otherwise `403 PERMISSION_DENIED`, and the same refusal when no permission resolver is registered or it throws (#30237, ADR-0148 D5) | `assertCallerMayRestoreEntry` |
160160
| 29f | Listing the recycle bin of an object asks **no recycle-bin grant** | objectql | Get: the system lists every entry of any object the bin takes. Every caller that is not system lists an object's entries only when its effective permissions grant `manageRecycleBin` on the object; otherwise `403 PERMISSION_DENIED`, and the same refusal when no permission resolver is registered or it throws (#30237, ADR-0148 D5) | `assertCallerManagesRecycleBin` |
161+
| 29g | A validation rule message's `{{ }}` holes show **every field the system may read**, only when the write names no person | objectql | Get: a user-less system write (a schedule, a platform sweep) fills a refused write's message holes with the security service's system answer, every field less credential and `internal` ones; that sentence reaches the server log alone. An elevated write that names a person (`userId`: a `runAs: 'system'` flow they started, whose refusal reaches them as `innerRefusal`; an action body; the approvals mirror) is not read as the system: both field projections are asked for that person, with the permission sets the context carries or their own grants (`resolveUserAuthzGrants`), and every hole renders empty when those grants cannot be read (#37909) | `readerContext` |
161162
| 30 | **Bulk data event `organizationId` OMITTED** — the batch is published "not asserted" | plugin-security | Get: nothing — the `data.records.*` event still publishes. Lose: the per-organization attribution: this exit is taken before the security middleware composes any tenant wall, so it records no Layer 0 verdict on the operation (`OperationContext.tenantLayer0Verdict`, #15813), and the engine's bulk producer — which reads that recorded verdict and nothing else — omits the key rather than filling it from the caller's `tenantId`; a tenant-scoped consumer then does not deliver the event inside an organization wall (#15225) | `registerAuthzMiddleware` |
162163
| 30b | **The import doors admit a control opt-out** — `runAutomations: false` and `treatAsHistorical: true` on `POST /data/:object/import` and `/import/jobs` | rest | Get: an import whose rows are written with `skipAutomations` (no metadata-bound hook, no record-change trigger: an app's approvals and record freezes among them) or with `skipStateMachine` and `preserveAudit`. Every other caller, every signed-in user and administrator included, is refused `403 PERMISSION_DENIED` before the body is parsed, so nothing is written and no job is created. Inbound HTTP never carries the flag, so this is an in-process caller's door. Note: the flag still suppresses none of those controls by itself (see below); it only admits the opt-outs that do | `importControlOptOutRefusal` |
163164
| 30c | **The import undo keeps the control skips** — `POST /data/import/jobs/:jobId/undo` | rest | Get: an undo whose deletes and restores are written with `skipAutomations` and `skipStateMachine`, so no metadata-bound hook, record-change trigger or `state_machine` rule refuses a reversal. Every other caller, every signed-in user and administrator included, undoes under those controls: a reversal one of them refuses is reported per row in the undo answer's `failures` and kept in the job's undo log, and the job is stamped reverted only once every row is. A historical job's `preserveAudit` belongs to the job, not the caller, and rides every undo. Inbound HTTP never carries the flag, so this is an in-process caller's door | `importUndoWriteContext` |
@@ -561,6 +562,7 @@ and CI refuses one that differs from what the tree produces.
561562
| `packages/objectql/src/engine-referential-integrity.ts#masterDetailHeadersCallerReads` | 1 | 29c |
562563
| `packages/objectql/src/engine-referential-integrity.ts#referencesCheckedBeforeRules` | 1 | 23 |
563564
| `packages/objectql/src/engine-referential-integrity.ts#storedReferencesCallerReads` | 1 | 23 |
565+
| `packages/objectql/src/engine-rule-message-rendering.ts#readerContext` | 1 | 29g |
564566
| `packages/objectql/src/engine-scoped-context.ts#appAuthoredHookApi` | 1 | 1b |
565567
| `packages/objectql/src/engine-secret-internal-fields.ts#encryptSecretFields` | 1 | 23e |
566568
| `packages/objectql/src/engine-secret-internal-fields.ts#stripSearchCompanionFromRead` | 1 | 27 |

‎packages/lint/src/validate-rule-message-templates.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* `objects.OBJECT._validations.RULE.message` translations — as the ADR-0032 §3
66
* `{{ }}` template it is, over the judged record.
77
*
8-
* The roots are the spec's, `VALIDATION_MESSAGE_TEMPLATE_ROOTS`
8+
* The roots are the spec's, `VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS`
99
* (`@objectstack/spec/data`): `record`, the merged record the rule judged, and
1010
* `previous`, the stored row before an update. Three steps, the action copy
1111
* pass's two (`validate-action-copy-templates.ts`) and one that is the rule
@@ -35,7 +35,7 @@
3535

3636
import { validateExpression } from '@objectstack/formula';
3737
import { closedScopeTemplateRefusal } from '@objectstack/spec/automation';
38-
import { VALIDATION_MESSAGE_TEMPLATE_ROOTS } from '@objectstack/spec/data';
38+
import { VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS } from '@objectstack/spec/data';
3939
import { nearestName } from './object-graph.js';
4040
import type { ExprIssue } from './validate-expressions.js';
4141

@@ -55,7 +55,7 @@ const HOLE = /\{\{([^}]*)\}\}/g;
5555
/** A hole's path — the template engine's `PATH_ONLY_RE`; a hole that fails it is the compile step's to name. */
5656
const HOLE_PATH = /^[\w$.[\]]+$/;
5757

58-
const ROOTS: ReadonlySet<string> = new Set(VALIDATION_MESSAGE_TEMPLATE_ROOTS);
58+
const ROOTS: ReadonlySet<string> = new Set(VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS);
5959

6060
/** A path's segments as the engine resolves them (`[i]` read as `.i`). */
6161
function segmentsOf(path: string): string[] {
@@ -129,7 +129,7 @@ export function ruleMessageTemplateIssues(text: unknown, site: RuleMessageSite):
129129
const refuse = (message: string, source: string): void => {
130130
issues.push({ where: site.where, message, source, severity: 'error', ...(site.path ? { path: site.path } : {}) });
131131
};
132-
const refusal = closedScopeTemplateRefusal(text, { slot: site.slot, roots: VALIDATION_MESSAGE_TEMPLATE_ROOTS });
132+
const refusal = closedScopeTemplateRefusal(text, { slot: site.slot, roots: VALIDATION_RULE_MESSAGE_TEMPLATE_ROOTS });
133133
if (refusal !== undefined) {
134134
refuse(refusal, text);
135135
return issues;

‎packages/objectql/src/engine-insert.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import type {
8181
} from './engine-top-level.js';
8282
import { ObjectQLStatics as ObjectQL } from './engine.js';
8383
import type { InsertManyRowOutcome, ObjectQL as ObjectQLClass } from './engine.js';
84+
import { attachRuleMessageRendering } from './engine-rule-message-rendering.js';
8485

8586
/**
8687
* The `ObjectQL` members the bodies of {@link InsertFacet} read — every one of
@@ -1190,6 +1191,9 @@ export class InsertFacet {
11901191
// Locale + translation hooks for the rejection messages (#3957) —
11911192
// resolved once for the batch, identical for every row.
11921193
const msgCtx = this.validationMessageContext(object, opCtx.context);
1194+
// [#37909] What a rule message's `{{ }}` holes may show on this write,
1195+
// and the currency they format in — computed once, beside the context.
1196+
await attachRuleMessageRendering(msgCtx, this.facade, this.logger, object, schemaForValidation, opCtx.context);
11931197
// [#3407 / #5126] This is the strip site both standing notes on
11941198
// `insert()` pointed at, so both members of `WriteObservabilityOptions`
11951199
// discharge here — the same one-per-call choice `update` offers, and by

0 commit comments

Comments
 (0)