You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ea1b70a
Browse filesBrowse the repository at this point in the historyBrowse 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>
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.
| 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 errornames 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) |
Copy file name to clipboardExpand all lines: content/docs/references/api/export.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,7 +232,7 @@ const result = CreateImportJobRequestSchema.parse(data);
232
232
|**field**|`string`| optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
233
233
|**code**|`string`| optional | Error code (failed rows; element 0 of `errors` when present) |
234
234
|**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. |
236
236
|**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. |
237
237
|**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. |
|**field**|`string`| optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
363
363
|**code**|`string`| optional | Error code (failed rows; element 0 of `errors` when present) |
364
364
|**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. |
366
366
|**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. |
367
367
|**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. |
|**field**|`string`| optional | Field that caused a coercion/validation error (element 0 of `errors` when present) |
383
383
|**code**|`string`| optional | Error code (failed rows; element 0 of `errors` when present) |
384
384
|**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. |
386
386
|**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. |
387
387
|**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. |
0 commit comments