Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/36794-wizard-reference-out-of-scope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/spec': patch
'@objectstack/core': patch
'@object-ui/plugin-grid': patch
'@object-ui/i18n': patch
---

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

Clause-②: yes (widening)
Metadata-protocol: none

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.

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.

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.

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.
2 changes: 1 addition & 1 deletion content/docs/api/error-catalog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ snake_case, so the code and the schema property are the same word.
| Presence and shape | `required`, `invalid_type`, `invalid_shape`, `unknown_field` |
| Per-type parse | `invalid_boolean`, `invalid_number`, `invalid_date`, `invalid_time`, `invalid_email`, `invalid_url`, `invalid_phone`, `invalid_json`, `invalid_format` |
| Bounded ranges | `min_length`, `max_length`, `min_value`, `max_value`, `max_scale`, `max_precision`, `min_items`, `max_items` |
| 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`) |
| 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) |
| Declarative rules | `rule_violation`, `json_schema_violation`, `invalid_initial_state`, `invalid_transition` |

Branch on `code` to decide *how* to mark an input; show `message` to the user.
Expand Down
9 changes: 9 additions & 0 deletions content/docs/data-modeling/import-mappings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ scoped lookup refused, and the cell fails with `reference_not_found`, even for a
that caller can read and whose name is unique. Without the master (or the `dependsOn`
sibling) in the row, the same cell resolves.

A `dependsOn` entry whose `param` names a target field the engine cannot filter by (a
`formula`) cannot scope the lookup at all: the engine refuses every scoped read, so the cell
fails with `reference_not_found` and a sentence that says the lookup could not be made within
the scope and names the cause (`Task: "Design review" could not be looked up within Project =
"Gemini": the target field this lookup's dependsOn filters by cannot be filtered on, …`),
never `reference_out_of_scope`. Point `param` at a stored field of the target. A scoped
lookup whose reads are refused for any other reason, such as no read access to the target,
keeps the plain `no record matches` sentence.

A pasted id is scoped too, so a row that means another master's detail cannot be linked
in one import. Correct the master cell; or, when the cross-master link is intended, leave
the master column out of the import and set it in a second update. For the
Expand Down
6 changes: 3 additions & 3 deletions content/docs/references/api/export.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const result = CreateImportJobRequestSchema.parse(data);
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
| **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. |
| **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. |
| **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. |
| **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. |

Expand Down Expand Up @@ -362,7 +362,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
| **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. |
| **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. |
| **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. |
| **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. |

Expand All @@ -382,7 +382,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo
| **field** | `string` | optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
| **code** | `string` | optional | Error code (failed rows; element 0 of `errors` when present) |
| **error** | `string` | optional | Human-readable error message (failed rows; element 0 of `errors` when present) |
| **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. |
| **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. |
| **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. |
| **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. |

Expand Down
22 changes: 21 additions & 1 deletion packages/core/src/utils/import-coerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ export interface RefMatch {
* as a record under another parent.
*/
scopeDenied?: boolean;
/**
* [#36794] The SCOPED lookup asked nothing: no candidate read answered, and
* the engine's filter seam refused a read because the scope names a target
* field it cannot filter by (a formula), judged off that refusal's declared
* `code` and `fields`. Every other all-refused lookup is a plain miss. The
* refusal stays `reference_not_found` and says the lookup could not be made
* within the row's scope, never that the value lives under another parent.
*/
scopeUnqueryable?: boolean;
}

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