Skip to content

Commit ea1b70a

Browse files
feat(plugin-grid,core): the Import Wizard names the column a lookup cell was scoped by; a scope no read could filter by says so (#37706)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuDqyPrPQvkURDXnUDgkyFWB)_ Fixes #36794 (PR-2 of 2; PR-1 #37567 landed the spec reason and the importer) Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 导入向导在预检和完成页上,对“查找值属于另一个父记录”的情况显示专门的提示,例如 `"Design review" was found, but not under Project "Gemini"`。提示会用标签说出限定它的列和本行填的值,11 种界面语言都已翻译。 - 补上契约审核提出的一个漏洞:如果 `dependsOn` 指向一个引擎无法筛选的字段(比如公式),限定查询一次都没跑成。这种情况以前会被误报成“在别的父记录下”,现在照旧报“找不到记录”,提示语改为说明无法在这个范围内查找,需要给 `dependsOn` 换一列。 - 只影响导入失败行的显示文字和一种配置错误时的错误码,成功导入不受影响,没有新增可写的元数据键。整张 PR 可以直接撤回。 - 无。 ## What changes - **Import Wizard** (`ui/packages/plugin-grid/src/ImportWizard.tsx`): `formatDryRunError` gains `case 'reference_out_of_scope'`, rendered from the cell error's structured `scope`. Each entry is named by the importing object's field label (its api-name when it has none) with the cell the row gave it, joined in the order the server sent them by the pack's own separator (`grid.import.scopeSeparator`: `、` in ja and zh, `، ` in ar; review N3). The Wizard keys on the code and `scope` only and never parses the server sentence; a cell error with no `scope` falls through to the server's own sentence (already in the caller's locale), the same path an unknown code takes. `scope` is carried onto `ImportResult.errors` by both the synchronous import mapping and `jobResultToImportResult`, so the completion screen renders the same text as the dry-run panel. New keys `grid.import.referenceOutOfScope`, `grid.import.scopeEntry` and `grid.import.scopeSeparator` are in the Wizard's default dictionary and in all 11 locales under `ui/packages/i18n/src/locales/`. - **Review nit 2, a scope no read could filter by** (`packages/core/src/utils/import-runner.ts`, `import-coerce.ts`): the resolver records whether any scoped candidate read ran to an answer, and whether a read was refused by the engine's filter seam for the scope: `isScopeFilterRefusal`, the declared `code: 'INVALID_FIELD'` naming a scope field in `fields`, read off the refusal like `isScopeFieldDenial`, never its message. Only when no read answered and such a refusal was seen (the `dependsOn` `param` names a target field the engine cannot filter by, such as a `formula`) does it return `RefMatch.scopeUnqueryable`. A lookup whose reads are all refused for any other reason (no read grant on the target, a driver fault) keeps the plain miss and the plain sentence (contract review S1, 7204641031). That cell keeps `reference_not_found`, with no unscoped probe and no `scope`, and gets its own catalog sentence `import_reference_scope_unqueryable`, whose remedy names the target field the `dependsOn` entry filters by ("point that dependsOn entry at a stored field", review N1) (`packages/spec/src/system/validation-message.ts`, all four platform locales). **Chosen: the runtime answer, no lint.** A lint refusing such a `dependsOn` would refuse metadata that publishes today, which is a narrowing that needs its own card. Before this PR that cell answered `reference_out_of_scope` once the unscoped probe found the value, which claimed a fact the import never checked. - **Review nit 1**: `ImportRowResultSchema.errors` describe (`packages/spec/src/api/export.zod.ts`) and the runner's `ImportRowResult.errors` jsdoc now say a `reference_out_of_scope` element carries `scope`. Regenerated `content/docs/references/api/export.mdx`. - **Review nit 4**: `content/docs/api/error-catalog.mdx` now says `scope` names the row's own scoping columns and the cells the row gave them, not the parent's columns. - `content/docs/data-modeling/import-mappings.mdx`, scoped-lookup section: a `dependsOn` `param` naming a formula cannot scope the lookup, and the cell answers `reference_not_found` with the could-not-look-up sentence; any other refusal keeps the plain sentence. - Changeset: `@objectstack/spec`, `@objectstack/core`, `@object-ui/plugin-grid` and `@object-ui/i18n` patch. `Metadata-protocol: none`: no key enters `packages/spec/authorable-surface/*.json`, because `check:generated` moved only the references page. The new catalog key is message vocabulary, the same class as PR-1's `import_reference_out_of_scope`, which its claim also read as `none`. `Clause-②: yes (widening)`: a new catalog key a deployment can override, and a wire answer that only becomes more precise for a case no released version answered `reference_out_of_scope` for. ## Tests - **Review nit 3, a real engine and the real field guard** (`packages/qa/dogfood/test/import-reference-out-of-scope.dogfood.test.ts`): a booted stack with the real `SecurityPlugin`, ObjectQL, SQL driver and the REST import door, plus a fixture member whose permission set hides `oos_task.project`. The guard is shown live first: the member's filter on that field gets 403, the admin's gets 200. The pins: - Admin, a task of another project: `reference_out_of_scope` with `scope: [{ field: 'project', value: 'Gemini' }]`. The in-scope row resolves and stores the id. A value nobody has: `reference_not_found` with no `scope`. - Member, the same rows: `reference_not_found`, plain sentence, no `scope`, including the row whose task really is under its own project. - A `dependsOn` whose `param` is a formula: `reference_not_found` with the `import_reference_scope_unqueryable` sentence. - None of these reads the guard's reason across a package as a string. Each answer comes from the real seam. - Ablation (dogfood): with the `isScopeFieldDenial` branch disabled, the member pin goes red. With the `scopeUnqueryable` assignment disabled, the formula pin goes red (2 failed / 2 passed). Restored: 4 passed. - `packages/core/src/utils/import-runner-reference-master-scope.test.ts`: a new pin in which every scoped read is refused `INVALID_FIELD` naming the scope field. It answers `reference_not_found` with the new sentence, no `scope`, and no unscoped probe. Two pins for S1: every read refused `PERMISSION_DENIED` naming no field, and every read refused `INVALID_FIELD` naming a field outside the scope; both answer the plain sentence. - `packages/spec/src/system/validation-message.test.ts`: every locale of `import_reference_scope_unqueryable` interpolates `{{value}}` and `{{scope}}` and names `dependsOn`; the English render. - `ui/packages/plugin-grid/src/importDryRun.test.ts`: the new case names the scope column by its label and the row's cell; a multi-column scope names every column (one without a label by api-name), joined by the pack's separator; it is never rendered as "no matching record"; with no `scope`, the server sentence is shown minus the api-name prefix. `importAsyncPath.test.ts`: `jobResultToImportResult` carries `scope` onto the error. <details><summary>Local readings (tree 8b99fd1, on main fbcfdfb; round 2 head f9dcf30: core master-scope 19 passed, spec validation-message 45 passed, dogfood out-of-scope 4 passed, ui i18n + plugin-grid 428 files / 4822 passed, plugin-grid type-check and core tsc green)</summary> - `pnpm --filter @objectstack/spec check:generated --fix`: 1 stale (`content/docs/references/**`, the `errors` describe), green after; nothing under `packages/spec/authorable-surface/` moved. - `typecheck` core and spec: green. `type-check` `@object-ui/plugin-grid` and `@object-ui/i18n` (deps built): green. `lint` plugin-grid: 0 errors. - `pnpm --dir ui exec vitest run packages/i18n/ packages/plugin-grid/`: two i18n census pins moved with the new keys and were updated in this PR (`de-quote-pairing-3876`, 133 → 135 paired spans; `untranslated-identity-4376`, `grid.import.scopeEntry` allowlisted as a format string). After that: i18n 111 files / 2028 passed; plugin-grid files green (the first run's only 3 failures were those two i18n pins). - spec `src/system/` + `src/data/mapping.test.ts`: 80 files / 2841 passed. core `src/utils/`: 51 files / 1356 passed. - dogfood `import-reference-out-of-scope` + `import-reference-exposure`: 2 files / 15 passed (core built from this tree). - `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0 (main, #37676, #37667, #37422). </details> ## Acceptance notes - The unfilterable-scope cell keeps the `reference_not_found` code, so the Wizard shows its generic "No matching record" text there. The precise sentence reaches API callers in the cell error's `message`. That case is an authoring mistake that a Wizard user cannot fix, and a code of its own would be a new `FieldErrorCode` member, which needs its own contract review. Left as it is. ## Verification Read first: `formatDryRunError` in `ImportWizard.tsx` (`case 'reference_out_of_scope'`), the resolver's `lookup` in `import-runner.ts` (`asked`, `scopeUnqueryable`), and `referenceNotFound` in `import-coerce.ts`. Two-minute check: `pnpm --dir ui exec vitest run packages/plugin-grid/src/importDryRun.test.ts -t "reference_out_of_scope"` runs 4 tests, all green. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX <!-- signed: repo:objectstack#2 · os-sales · session_01L6bhgWgMUXf5juNBhN6rLX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f722411 commit ea1b70a

27 files changed

Lines changed: 511 additions & 14 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/core': patch
4+
'@object-ui/plugin-grid': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(plugin-grid,core): the Import Wizard names the column a lookup cell was scoped by when the value belongs to another parent; a scope no read could filter by says so
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: none
12+
13+
The Import Wizard's dry run and completion screen render the import cell error `reference_out_of_scope` (#36794) with their own text, `"Design review" was found, but not under Project "Gemini"`, built from the cell error's `scope` (each scoping column by its label, with the cell the row gave it) and translated in all eleven UI locales (`grid.import.referenceOutOfScope`, `grid.import.scopeEntry`). The Wizard keys on the code and the structured `scope`, never on the server's sentence; a cell error with no `scope` shows the server's own sentence, already in the caller's locale.
14+
15+
The importer no longer reports a scoped lookup as `reference_out_of_scope` when the engine refused its scoped reads because of the scope: a `dependsOn` whose `param` names a target field the engine cannot filter by (a `formula`) has every scoped read refused (`INVALID_FIELD` naming that field), so the scope was never asked. That cell keeps `reference_not_found`, with its own catalog sentence `import_reference_scope_unqueryable` in all four platform locales, which says the lookup could not be made within the scope and that the `dependsOn` entry should point at a stored target field. No unscoped probe runs for it and it carries no `scope`. A scoped lookup whose reads are all refused for any other reason (no read access to the target, say) keeps the plain `no record matches` sentence.
16+
17+
Wording: `ImportRowResultSchema.errors` and the runner's `ImportRowResult.errors` now say that a `reference_out_of_scope` element carries `scope`; the error catalog page says `scope` names the row's own scoping columns, not the parent's.
18+
19+
What to do: nothing. A client that matches `reference_not_found` for "the lookup cell did not resolve" keeps receiving it for the unfilterable scope.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ snake_case, so the code and the schema property are the same word.
930930
| Presence and shape | `required`, `invalid_type`, `invalid_shape`, `unknown_field` |
931931
| Per-type parse | `invalid_boolean`, `invalid_number`, `invalid_date`, `invalid_time`, `invalid_email`, `invalid_url`, `invalid_phone`, `invalid_json`, `invalid_format` |
932932
| Bounded ranges | `min_length`, `max_length`, `min_value`, `max_value`, `max_scale`, `max_precision`, `min_items`, `max_items` |
933-
| Closed sets and references | `invalid_option`, `value_domain` (the written value is not a member of the field's declared `valueDomain` standard), `invalid_value`, `reference_not_found`, `reference_ambiguous`, `reference_out_of_scope` (an import lookup cell whose value matches a record only under another parent than the row's own; the cell error names that parent's columns in `scope`) |
933+
| Closed sets and references | `invalid_option`, `value_domain` (the written value is not a member of the field's declared `valueDomain` standard), `invalid_value`, `reference_not_found`, `reference_ambiguous`, `reference_out_of_scope` (an import lookup cell whose value matches a record only under another parent than the row's own; the cell error's `scope` names the row's own scoping columns and the cells the row gave them) |
934934
| Declarative rules | `rule_violation`, `json_schema_violation`, `invalid_initial_state`, `invalid_transition` |
935935

936936
Branch on `code` to decide *how* to mark an input; show `message` to the user.

‎content/docs/data-modeling/import-mappings.mdx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,15 @@ scoped lookup refused, and the cell fails with `reference_not_found`, even for a
369369
that caller can read and whose name is unique. Without the master (or the `dependsOn`
370370
sibling) in the row, the same cell resolves.
371371

372+
A `dependsOn` entry whose `param` names a target field the engine cannot filter by (a
373+
`formula`) cannot scope the lookup at all: the engine refuses every scoped read, so the cell
374+
fails with `reference_not_found` and a sentence that says the lookup could not be made within
375+
the scope and names the cause (`Task: "Design review" could not be looked up within Project =
376+
"Gemini": the target field this lookup's dependsOn filters by cannot be filtered on, …`),
377+
never `reference_out_of_scope`. Point `param` at a stored field of the target. A scoped
378+
lookup whose reads are refused for any other reason, such as no read access to the target,
379+
keeps the plain `no record matches` sentence.
380+
372381
A pasted id is scoped too, so a row that means another master's detail cannot be linked
373382
in one import. Correct the master cell; or, when the cross-master link is intended, leave
374383
the master column out of the import and set it in a second update. For the

‎content/docs/references/api/export.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ const result = CreateImportJobRequestSchema.parse(data);
232232
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
233233
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
234234
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
235-
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
235+
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. A `reference_out_of_scope` cell error also carries `scope`: the row's own columns the lookup was resolved within, each with the cell the row gave it. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
236236
| **warnings** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Findings this deployment ADMITS rather than rejects, copied verbatim from the validate verdict's row `warnings`: ADR-0104 value shapes under a warn-first posture, then the hits of advisory validation rules (`severity: 'warning'` or `'info'`, each naming its `rule` and `severity`). Set only on a dry-run row the verdict accepted: the row is `ok` because the write would store it. A committed row does not carry it: the import does not copy a write answer's `warnings` onto the row. |
237237
| **droppedFields** | `{ object: string; fields: string[]; reason: Enum<'readonly' \| 'readonly_when' \| 'primary_key' \| 'computed' \| 'stored_expression'> }[]` | optional | Write-observability: caller-supplied fields the engine LEGALLY strips from THIS row, one event per reason, in the engine's own `droppedFields` shape and reason vocabulary. A committed row reports the strips its write made. A dry-run row reports the strips its preview runs, which for a row the import would update excludes `readonlyWhen` and primary-key strips, so that row can name fewer fields than its commit. The row still succeeds: `ok` and `action` are unchanged. Present only when at least one field was dropped. A server or write path that does not produce this report omits the key too, so an absent key alone does not prove nothing was dropped. In an async job's `results`, an ok row's drops reach the reader only if the row falls inside that capped, failures-first sample. |
238238

@@ -362,7 +362,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo
362362
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
363363
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
364364
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
365-
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
365+
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. A `reference_out_of_scope` cell error also carries `scope`: the row's own columns the lookup was resolved within, each with the cell the row gave it. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
366366
| **warnings** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Findings this deployment ADMITS rather than rejects, copied verbatim from the validate verdict's row `warnings`: ADR-0104 value shapes under a warn-first posture, then the hits of advisory validation rules (`severity: 'warning'` or `'info'`, each naming its `rule` and `severity`). Set only on a dry-run row the verdict accepted: the row is `ok` because the write would store it. A committed row does not carry it: the import does not copy a write answer's `warnings` onto the row. |
367367
| **droppedFields** | `{ object: string; fields: string[]; reason: Enum<'readonly' \| 'readonly_when' \| 'primary_key' \| 'computed' \| 'stored_expression'> }[]` | optional | Write-observability: caller-supplied fields the engine LEGALLY strips from THIS row, one event per reason, in the engine's own `droppedFields` shape and reason vocabulary. A committed row reports the strips its write made. A dry-run row reports the strips its preview runs, which for a row the import would update excludes `readonlyWhen` and primary-key strips, so that row can name fewer fields than its commit. The row still succeeds: `ok` and `action` are unchanged. Present only when at least one field was dropped. A server or write path that does not produce this report omits the key too, so an absent key alone does not prove nothing was dropped. In an async job's `results`, an ok row's drops reach the reader only if the row falls inside that capped, failures-first sample. |
368368

@@ -382,7 +382,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo
382382
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
383383
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
384384
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
385-
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
385+
| **errors** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Every cell error of a failed row, one element per failed cell, in the validate verdict's issue shape (`field`, `code`, `message`). The list holds the import's cell-coercion errors, and a cell error never carries the advisory-only `rule` or `severity`. A `reference_out_of_scope` cell error also carries `scope`: the row's own columns the lookup was resolved within, each with the cell the row gave it. Present only on a failed row that has at least one cell error, so a row that failed for another reason (a duplicate or ambiguous match key, say) omits it. The first-error keys `field`, `code` and `error` stay and name element 0, so a reader of those keys sees the same answer as before. A server that does not produce this list omits the key, and the row then reports its first error only. |
386386
| **warnings** | `{ field: string; code: string; message: string; rule?: string; … }[]` | optional | Findings this deployment ADMITS rather than rejects, copied verbatim from the validate verdict's row `warnings`: ADR-0104 value shapes under a warn-first posture, then the hits of advisory validation rules (`severity: 'warning'` or `'info'`, each naming its `rule` and `severity`). Set only on a dry-run row the verdict accepted: the row is `ok` because the write would store it. A committed row does not carry it: the import does not copy a write answer's `warnings` onto the row. |
387387
| **droppedFields** | `{ object: string; fields: string[]; reason: Enum<'readonly' \| 'readonly_when' \| 'primary_key' \| 'computed' \| 'stored_expression'> }[]` | optional | Write-observability: caller-supplied fields the engine LEGALLY strips from THIS row, one event per reason, in the engine's own `droppedFields` shape and reason vocabulary. A committed row reports the strips its write made. A dry-run row reports the strips its preview runs, which for a row the import would update excludes `readonlyWhen` and primary-key strips, so that row can name fewer fields than its commit. The row still succeeds: `ok` and `action` are unchanged. Present only when at least one field was dropped. A server or write path that does not produce this report omits the key too, so an absent key alone does not prove nothing was dropped. In an async job's `results`, an ok row's drops reach the reader only if the row falls inside that capped, failures-first sample. |
388388

‎packages/core/src/utils/import-coerce.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ export interface RefMatch {
9696
* as a record under another parent.
9797
*/
9898
scopeDenied?: boolean;
99+
/**
100+
* [#36794] The SCOPED lookup asked nothing: no candidate read answered, and
101+
* the engine's filter seam refused a read because the scope names a target
102+
* field it cannot filter by (a formula), judged off that refusal's declared
103+
* `code` and `fields`. Every other all-refused lookup is a plain miss. The
104+
* refusal stays `reference_not_found` and says the lookup could not be made
105+
* within the row's scope, never that the value lives under another parent.
106+
*/
107+
scopeUnqueryable?: boolean;
99108
}
100109

101110
/**
@@ -178,6 +187,11 @@ interface ScopedBy {
178187
* A scoped read the field-predicate guard refused (`RefMatch.scopeDenied`: the
179188
* scope names a target field the caller cannot read) is never probed: its miss
180189
* says nothing about where the value lives, so it stays `reference_not_found`.
190+
* A scoped lookup none of whose reads answered because the engine's filter seam
191+
* refused the scope (`RefMatch.scopeUnqueryable`: the scope names a target field
192+
* the engine cannot filter by, such as a formula) is not probed either: it
193+
* stays `reference_not_found` with its own sentence, which says the lookup
194+
* could not be made within the row's scope.
181195
*
182196
* The probe is the caller's own read: the resolver runs every lookup as the
183197
* importing principal, so it can find only a record that principal can already
@@ -199,9 +213,15 @@ async function referenceNotFound(
199213
// A scope the caller may not filter by was never asked: nothing is known about
200214
// where the value lives, so it is not "under another parent".
201215
if (scopedMatch.scopeDenied) return refusal;
216+
const qualifier = scopedBy.map((s) => `${s.label} = "${s.value}"`).join(', ');
217+
// A scope no read could filter by: say the lookup could not be made, not that nothing matched.
218+
if (scopedMatch.scopeUnqueryable) {
219+
return coerceError(
220+
meta, field, 'reference_not_found', 'import_reference_scope_unqueryable', value, ctx, { scope: qualifier },
221+
);
222+
}
202223
const unscoped = normalizeRefMatch(await ctx.resolveRef(meta.reference, value, meta));
203224
if (unscoped.id === undefined && !unscoped.ambiguous) return refusal;
204-
const qualifier = scopedBy.map((s) => `${s.label} = "${s.value}"`).join(', ');
205225
const outOfScope = coerceError(
206226
meta, field, 'reference_out_of_scope', 'import_reference_out_of_scope', value, ctx, { scope: qualifier },
207227
);

0 commit comments

Comments
 (0)