Skip to content

Commit 0346b57

Browse files
fix(lint)!: refuse a grid list view grouped by a dotted path (#38789)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} --> _Requested by **Irene** · [project thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67x7k1r5UkqrK3zRZHZJKat5c)_ Fixes #38654 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: follow-up #38655 ## 维护者速读 - 作者在命令行校验或在设计器保存表格列表视图时,若按「关联记录的某个字段」这种带点的路径分组,会被直接拒绝并给出改法;看板、日历等其它视图不受影响,运行中的用户无感。 - 属于「发布时拦下保存成功却用不了的元数据」这一组检查,补上上一张表格分组检查卡(不可分组字段)留下的最后一类:带点路径。 - 碰到的是已经这样分组的表格视图作者,下次保存会被拒(这样的视图本来一打开就报错,平台自带视图和示例应用无一受影响);撤回本合并即可恢复原状。 - 无 ## What changes - `list-view-field-dotted` (`error`) now also judges a grid list view's `grouping.fields[].field` (a view whose `type` is `grid`, or absent, since the schema defaults it to `grid`). The grid sends its grouping as the group header query, and `engine.aggregate` refuses a `groupBy` entry naming a dotted name the object does not declare verbatim, whatever its head or leaf (`assertGroupByTargetsAreStored`, `packages/objectql/src/aggregate-query-shape-door.ts:231`, `400 INVALID_FIELD`). Until now lint passed `account.name` there and the grid opened on that error. - The verdict asks the engine's own condition (dotted, and not a declared field name), so `account.name` and `account.tags` are refused alike. It is judged where the head resolves; a head that resolves to nothing stays `list-view-field-unknown`, reported once. - Same doors and same kind gate as the item-3 rule (`list-view-group-field-ungroupable`): `os validate` / `lint` / `compile` / `build`, and the runtime save door on `view` and `object` writes; `kanban`, `gallery`, `calendar`, `timeline`, `gantt`, `map`, `chart`, `tree` and `timesheet` are not judged (their grouping does not reach the engine). `DOTTED_AXIS` is deliberately NOT given a `grouping` row: that table has no kind gate, so a row there would refuse a kanban's client-side swimlane field. - The fix line reads the head the way the engine's message does: a single-valued relation head gets "Group by `account` itself (one group per related record)"; any other head gets "Group by a stored single-valued field". Both also offer denormalising the value onto the object. - Module header corrected: `grouping.fields` left the "reach no door this card measured" list, and a new section `[#38654] A dotted grouping.fields[].field on a grid` states the verdict. - `os explain list-view-field-dotted` gains the grouping-level position, its door and its fix; `os explain list-view-group-field-ungroupable` now names `list-view-field-dotted` as the rule for a dotted name. - ADR-0087 semantic entry `publish-refuses-list-view-grouping-by-a-dotted-path` (`@objectstack/spec` patch) and a minor `@objectstack/lint` changeset with a BREAKING banner and FROM → TO. - A parity pin in `packages/objectql` feeds one set of names to the engine door and to the linter and holds them to one answer (claim amendment 7282613519; test only, no objectql runtime file changes). The engine's predicate is inline in the door and `@objectstack/lint` may not import a runtime, so the pin is where "the engine's own predicate as the judge" lives. First-party impact, measured at 8a7e65b: the 7 first-party list views that declare a grouping (`packages/platform-objects` ×6, `plugin-approvals` ×1) all group by an undotted stored field; `examples/**` and `packages/apps/**` declare none; `objectstack-ai/hotcrm` declares no dotted grouping. 0 findings. Contract face: the lint rule's accept set narrows. This PR stays draft for the CONTRACT_REVIEW_TIER review the seat routes. ## Read first 1. `packages/lint/src/validate-list-view-field-refs.ts`: `checkGroupFieldDotted` and its call at the top of `checkGroupField` (the kind gate runs before it). 2. `packages/objectql/src/aggregate-query-shape-door.group-by-dotted-lint-parity.test.ts`: the engine door and the linter on the same names. 3. `.changeset/38654-list-view-grouping-dotted-path.md`: the BREAKING banner and FROM → TO. ## Two-minute check `pnpm --filter @objectstack/lint exec vitest run src/validate-list-view-field-refs.group-field-38433.test.ts`: 41 passed (the 20 new `[#38654]` cases among them). ## Tests - `validate-list-view-field-refs.group-field-38433.test.ts`, new top-level `describe('[#38654] …')`, 20 cases: five refused paths (`account.name`, `account.tags`, `owners.name`, `meta.x`, `title.x`), each asserting rule, `error`, `where`, `path`, the message and the head-specific fix line; the relation itself as a quiet control; an unknown head stays `list-view-field-unknown` alone; an untyped (grid) view; six non-grid kinds quiet; a multi-level grouping; `validate` and `build` fail; the runtime `view` save door (refused, then admitted on `account`); the runtime `object` save door through `listViews`; the `os explain` entry. The item-3 dotted case keeps its assertion (not that rule's verdict) and points at the new block. - `validate-list-view-field-refs.test.ts`: the "renderer bindings stay unjudged" pin drops its `grouping.fields` entry, which a grid now judges. - New `packages/objectql/src/aggregate-query-shape-door.group-by-dotted-lint-parity.test.ts`, 9 cases: five dotted names the engine refuses (`INVALID_FIELD` / 400) and the linter reports as `list-view-field-dotted`; an object-qualified name both refuse (the linter as `list-view-field-unknown`); three stored single-valued controls both accept. <details><summary>Readings</summary> - Head 03c61bf, merge base 8a7e65b (origin/main). - The four list-view suites (`validate-list-view-field-refs.group-field-38433`, `validate-list-view-field-refs`, `rule-explanations`, `validate-list-view-kanban-lanes`): Test Files 4 passed (4), Tests 294 passed (294). - Whole `@objectstack/lint` suite: Test Files 253 passed (253), Tests 10122 passed (10122). - objectql parity pin: Test Files 1 passed (1), Tests 9 passed (9). - `packages/spec/src/migrations`: Test Files 5 passed (5), Tests 210 passed (210). - `pnpm --filter @objectstack/lint typecheck`: `VERDICT command-exit 0`. `pnpm --filter @objectstack/objectql typecheck`: `VERDICT command-exit 0`, test layer held at its ledger. - Ablation 1, `scripts/ablation-replace.mjs --delete` of the `checkGroupFieldDotted(...)` call, over the lint file: anchor 1 to 0, blob 7efbe8a to 147d5a7679f2. 11 failed (five refused paths, untyped view, multi-level, validate, build, view door, object door), 30 passed. Restored: blob equals HEAD, `git diff HEAD` empty. - Ablation 2, the same deletion, over the objectql parity pin (lint resolves to source there through the package's vitest alias): 5 failed (the five dotted names), 4 passed. Restored the same way. </details> ## Verification <details><summary>Local gates on 03c61bf</summary> - `dispatch-gates.mjs --commands`: 98 derived families. `--ran` reconciliation: 98 accounted for, 94 run, 4 NOT MEASURED. - 94 exit 0, among them `check-adr-0087-registration.mjs --base origin/main`, `check-changeset-no-major.mjs --base origin/main`, `check-empty-changeset.mjs --base origin/main`, `check:spec-changes`, `check:upgrade-guide`, `check:docs`, `check:api-surface`, `check:authorable-surface`, `check:cross-package-test-inputs`, `check:test-source-alias`, `check:undeclared-dep-imports`, `check:nul-bytes`, `check:doc-authoring`, `check:issue-citations`. `check-plugin-teardown-shape.mjs --self-test` first exited 3 on the shallow clone (pinned fixture commit unreachable) and exited 0 after fetching that commit; `check:lean-entry-closure` first exited 3 (objectql dist absent) and exited 0 after building it. - NOT MEASURED: `pnpm --filter @objectstack/cli exec vitest run test/migrate-meta-engine-guidance.test.ts` (exit 1 MODULE_NOT_FOUND, the CLI's dependency closure is not built here; Test Core runs it); `check:dual-build-cjs-loads` (exit 3, needs a whole-workspace build); `check:query-options-erasure` and `check:type-check-debt` (exit 124, over a 280 s per-command budget on the shared box). CI runs all four. - `node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD`: 3 commit messages clean. </details> ## Acceptance notes - Claim lines copied verbatim: `Clause-②: no` (the claim carries no `(narrowing)` arm, though the title carries `!` and the changeset is BREAKING; `check-adr-0087-registration` and `check-changeset-no-major` pass with it). If the seat wants `no (narrowing)`, it is a one-word edit to the PR body and the changeset. --- _Generated by [Claude Code](https://claude.ai/code/session_01J8VVAnXAALduwvLNEgFqeY)_ <!-- signed: repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAnXAALduwvLNEgFqeY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f950e92 commit 0346b57

7 files changed

Lines changed: 333 additions & 13 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/lint': minor
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(lint)!: refuse a grid list view grouped by a dotted path
7+
8+
Clause-②: no (narrowing)
9+
Metadata-protocol: narrowed
10+
Skills-docs: follow-up #38655
11+
12+
<!-- adr-0087: registered publish-refuses-list-view-grouping-by-a-dotted-path -->
13+
14+
**BREAKING** for a `grid` list view (or one with no `type`, which defaults to `grid`) whose `grouping.fields[].field` is a dotted path such as `account.name`: it was accepted before and is refused now, with the fix named in the finding. The schema is unchanged and stored metadata is not rewritten or refused at boot; the refusal comes at the next publish of the view (a `view` write, or an `object` write through the object's own `listViews`), and from `os validate` / `lint` / `compile` / `build`.
15+
16+
- `list-view-field-dotted` (error) now also judges a grid list view's grouping level. A grid sends its grouping as the group header query, and the engine groups by the object's own fields by their bare names, 0 hops deep: it refuses a dotted name the object does not declare, whatever its head or leaf (`400 INVALID_FIELD`), so the view saved, then opened on that error and rendered no group. The verdict asks the engine's own condition, so `account.name` and `account.tags` are refused alike. A head that names no field stays `list-view-field-unknown`. Not judged: any other list-view kind (`kanban`, `gallery`, `calendar`, `timeline`, `gantt`, `map`, `chart`, `tree`, `timesheet`), where no door fails the view: a board's one grouped count read is refused and absorbed, and the board and the gallery read the name as a flat key of the row, so a dotted name there groups nothing.
17+
18+
## FROM → TO
19+
20+
- FROM: a `grid` list view with `grouping: { fields: [{ field: 'account.name' }] }` — saved, then the grid opened on `400 INVALID_FIELD`.
21+
- TO: group by the relation itself when it is a single-valued lookup (`grouping: { fields: [{ field: 'account' }] }`, one group per related record), or store the value on the object (a field written when the source changes) and group by that field.
22+
23+
`os explain list-view-field-dotted` and `os explain list-view-group-field-ungroupable` carry the new position. `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-list-view-grouping-by-a-dotted-path`.

‎packages/lint/src/rule-explanations.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4512,14 +4512,22 @@ const LIST_VIEW_FIELD_DOTTED_EXPLANATION: RuleExplanation = {
45124512
'Aggregate: a grouping level\'s `orderBy` is the operand of the `min` / `max` node the group ' +
45134513
'header query orders its groups by. The header query compiles no join, so the data door\'s ' +
45144514
'ingress refuses every dotted operand whatever its head (`assertAggregationFieldsExist`, ' +
4515-
'`400 INVALID_FIELD`), and the grouped view renders no group.',
4515+
'`400 INVALID_FIELD`), and the grouped view renders no group. A grouping level\'s `field` on a grid ' +
4516+
'(a list view whose `type` is `grid` or absent) is one `groupBy` column of that same query, and the ' +
4517+
'engine groups by the object\'s own fields by their bare names, 0 hops deep: a dotted name the object ' +
4518+
'does not declare is refused whatever its head or leaf (`assertGroupByTargetsAreStored`, ' +
4519+
'`400 INVALID_FIELD`), so `account.name` is refused exactly as `account.tags` is.',
45164520
'The ways out are the doors\' own. At a projection position, name the whole column and read ' +
45174521
'into its value in the client, or read the related record with `expand`; at a filter position, ' +
4518-
'filter on a column of the bound object itself. At either, denormalise the value onto the bound ' +
4519-
'object — a stored field, written when the source changes — and name that.',
4522+
'filter on a column of the bound object itself; at a grouping level whose head is a single-valued ' +
4523+
'relation, group by that relation itself, one group per related record. At any of them, denormalise ' +
4524+
'the value onto the bound object — a stored field, written when the source changes — and name that.',
45204525
'Not judged, because each is read client-side out of the fetched row, where a dotted path ' +
4521-
'walks an embedded record: `gantt.quickFilters[].field`, `gantt.tooltipFields[]` and every ' +
4522-
'renderer binding. `sort` keeps its own rule. Always an error: every judged position is ' +
4526+
'walks an embedded record: `gantt.quickFilters[].field`, `gantt.tooltipFields[]`, every ' +
4527+
'renderer binding. The grouping of every kind but a grid is not judged either, for another reason: ' +
4528+
'no door fails that view. A kanban board\'s one grouped count read is refused and absorbed, and the ' +
4529+
'board and the gallery read the name as a flat key of the row, walking no path, so a dotted name ' +
4530+
'there groups nothing. `sort` keeps its own rule. Always an error: every judged position is ' +
45234531
'refused outright by its door.',
45244532
],
45254533
};
@@ -4561,7 +4569,7 @@ const LIST_VIEW_GROUP_FIELD_UNGROUPABLE_EXPLANATION: RuleExplanation = {
45614569
'and publishes, then opens on that error and renders no group.',
45624570
'An error, so the publish is refused and `os validate` and `os build` fail. The verdict asks the same spec ' +
45634571
'predicates the engine asks, so it refuses exactly the three storage classes the engine refuses. A dotted ' +
4564-
'name is refused by the engine on another ground, which this verdict does not report. Judged on a list view ' +
4572+
'name is refused by the engine on another ground, reported as `list-view-field-dotted`. Judged on a list view ' +
45654573
'whose `type` is `grid` or absent (the default is `grid`); any other kind is not judged, because none was ' +
45664574
'measured to send its grouping to the engine: a gallery groups the cards it fetched, and a kanban board ' +
45674575
'keeps drawing its cards when its grouped count read is refused. Not judged either: a name that resolves ' +

‎packages/lint/src/validate-list-view-field-refs.group-field-38433.test.ts‎

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { runAuthoringRules, splitBySeverity } from './authoring-rules.js';
1717
import { explainRule } from './rule-explanations.js';
1818
import { runRuntimeAuthoringRules } from './runtime-gate.js';
1919
import {
20+
LIST_VIEW_FIELD_DOTTED,
21+
LIST_VIEW_FIELD_UNKNOWN,
2022
LIST_VIEW_GROUP_FIELD_UNGROUPABLE,
2123
validateListViewFieldRefs,
2224
} from './validate-list-view-field-refs.js';
@@ -102,7 +104,8 @@ describe('[#38433] a list view grouped by a field the engine does not group by',
102104
it('a dotted name is not this verdict: the engine refuses every dotted groupBy name on its own ground, multi-valued leaf or not', () => {
103105
// `account.tags` ends on a `tags` field, `account.name` on a text one; the
104106
// engine's dotted-name branch refuses both alike, so the storage class of
105-
// the leaf is not what the engine judges there.
107+
// the leaf is not what the engine judges there. [#38654] That ground is
108+
// `list-view-field-dotted`, pinned in its own block below.
106109
expect(ungroupable('account.tags')).toEqual([]);
107110
expect(ungroupable('account.name')).toEqual([]);
108111
});
@@ -164,3 +167,99 @@ describe('[#38433] a list view grouped by a field the engine does not group by',
164167
}
165168
});
166169
});
170+
171+
// [#38654] A grid grouping level whose `field` is a dotted path. The group
172+
// header query's `groupBy` is one of the object's own columns by its bare
173+
// name: `engine.aggregate` refuses a dotted name the object does not declare
174+
// verbatim, whatever its head or leaf (`assertGroupByTargetsAreStored`, 400
175+
// INVALID_FIELD). The engine door itself judges the same names in
176+
// `packages/objectql/src/aggregate-query-shape-door.group-by-dotted-lint-parity.test.ts`.
177+
describe('[#38654] a grid list view grouped by a dotted path', () => {
178+
const dotted = (listView: AnyRec) =>
179+
validateListViewFieldRefs(stackWith(listView)).filter((f) => f.rule === LIST_VIEW_FIELD_DOTTED);
180+
181+
it.each([
182+
['a text leaf through a single-valued lookup', 'account.name', 'Group by "account" itself'],
183+
['a multi-valued leaf through a single-valued lookup', 'account.tags', 'Group by "account" itself'],
184+
['a path through a multi-valued lookup', 'owners.name', 'Group by a stored single-valued field of "grp_task"'],
185+
['a path into a JSON-stored value', 'meta.x', 'Group by a stored single-valued field of "grp_task"'],
186+
['a path under a scalar field', 'title.x', 'Group by a stored single-valued field of "grp_task"'],
187+
])('refuses %s', (_label, field, remedy) => {
188+
const findings = validateListViewFieldRefs(stackWith(groupedBy(field)));
189+
expect(findings.map((f) => [f.rule, f.severity, f.where, f.path])).toEqual([
190+
[LIST_VIEW_FIELD_DOTTED, 'error', 'view "grp_task" › list › grouping', 'views[0].list.grouping.fields[0].field'],
191+
]);
192+
expect(findings[0].message).toContain(`"${field}" is a dotted path`);
193+
expect(findings[0].message).toContain('400 INVALID_FIELD');
194+
expect(findings[0].hint).toContain(remedy);
195+
for (const line of [findings[0].message, findings[0].hint]) {
196+
expect(line).not.toContain('\n');
197+
expect(line.length, line).toBeLessThanOrEqual(200);
198+
}
199+
});
200+
201+
it('CONTROL — the relation itself, a stored single-valued field, is quiet', () => {
202+
expect(validateListViewFieldRefs(stackWith(groupedBy('account')))).toEqual([]);
203+
});
204+
205+
it('a head that resolves to nothing stays `list-view-field-unknown`, reported once', () => {
206+
const findings = validateListViewFieldRefs(stackWith(groupedBy('acount.name')));
207+
expect(findings.map((f) => f.rule)).toEqual([LIST_VIEW_FIELD_UNKNOWN]);
208+
});
209+
210+
it('an absent `type` is a grid and is judged', () => {
211+
const { type: _type, ...untyped } = groupedBy('account.name');
212+
expect(dotted(untyped).map((f) => f.path)).toEqual(['views[0].list.grouping.fields[0].field']);
213+
});
214+
215+
it.each(['kanban', 'gallery', 'calendar', 'timeline', 'gantt', 'map'])(
216+
'CONTROL — a `%s` list view is not judged: no door fails its view (a refused board count read is absorbed)',
217+
(type) => {
218+
expect(dotted({ ...groupedBy('account.name'), type })).toEqual([]);
219+
},
220+
);
221+
222+
it('judges every level of a multi-level grouping', () => {
223+
const listView = { ...groupedBy('status'), grouping: { fields: [{ field: 'status' }, { field: 'account.name' }] } };
224+
expect(dotted(listView).map((f) => f.path)).toEqual(['views[0].list.grouping.fields[1].field']);
225+
});
226+
227+
for (const command of ['validate', 'build'] as const) {
228+
it(`fails \`${command}\``, () => {
229+
const { errors } = splitBySeverity(runAuthoringRules(command, { normalized: stackWith(groupedBy('account.name')) }));
230+
expect(errors.map((f) => f.rule)).toContain(LIST_VIEW_FIELD_DOTTED);
231+
});
232+
}
233+
234+
it('is refused at the runtime `view` save door, and admitted once the grouping names the relation itself', () => {
235+
const item = (field: string) => ({ name: 'grp_task', object: 'grp_task', list: groupedBy(field) });
236+
const refused = runRuntimeAuthoringRules({ type: 'view', item: item('account.name'), context: { objects: OBJECTS } });
237+
expect(refused.errors.map((f) => [f.rule, f.severity])).toEqual([[LIST_VIEW_FIELD_DOTTED, 'error']]);
238+
expect(refused.errors[0].path).toMatch(/grouping\.fields\[0\]\.field$/);
239+
const clean = runRuntimeAuthoringRules({ type: 'view', item: item('account'), context: { objects: OBJECTS } });
240+
expect(clean.errors).toEqual([]);
241+
});
242+
243+
it('is refused at the runtime `object` save door through the object\'s own list views', () => {
244+
const task = OBJECTS[0];
245+
const write = (field: string) =>
246+
runRuntimeAuthoringRules({
247+
type: 'object',
248+
item: { ...task, listViews: { by_account: groupedBy(field) } },
249+
context: { objects: OBJECTS },
250+
});
251+
const refused = write('account.name');
252+
expect(refused.errors.filter((f) => f.rule === LIST_VIEW_FIELD_DOTTED).map((f) => f.path)).toEqual([
253+
expect.stringMatching(/listViews\.by_account\.grouping\.fields\[0\]\.field$/),
254+
]);
255+
const clean = write('account');
256+
expect(clean.errors.filter((f) => f.rule === LIST_VIEW_FIELD_DOTTED || f.rule === LIST_VIEW_FIELD_UNKNOWN)).toEqual([]);
257+
});
258+
259+
it('`os explain` carries the grouping level, the engine door and the fix', () => {
260+
const text = explainRule(LIST_VIEW_FIELD_DOTTED)!.paragraphs.join('\n');
261+
for (const fact of ['grouping level\'s `field`', '`assertGroupByTargetsAreStored`', 'group by that relation itself']) {
262+
expect(text, fact).toContain(fact);
263+
}
264+
});
265+
});

‎packages/lint/src/validate-list-view-field-refs.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,9 @@ describe('#14282 — the measured exclusions: positions read CLIENT-SIDE', () =>
830830
objectField: 'owner.name',
831831
},
832832
tree: { parentField: 'owner.name' },
833-
grouping: { fields: [{ field: 'owner.name' }] },
833+
// [#38654] `grouping.fields` left this list: a grid sends it to the
834+
// aggregate door, so it is judged there (its pins live in
835+
// `validate-list-view-field-refs.group-field-38433.test.ts`).
834836
hiddenFields: ['owner.name'],
835837
fieldOrder: ['owner.name'],
836838
}),

‎packages/lint/src/validate-list-view-field-refs.ts‎

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,16 @@
163163
* through `resolvePath(record, fieldName)`, which walks dots. Excluded.
164164
* - **Every renderer binding** (`kanban` / `calendar` / `timeline` /
165165
* `gallery` / `map` / `tree` scalars, `rowColor.field`, `hiddenFields`,
166-
* `fieldOrder`, `grouping.fields`, `columns[].summary.field`, `kanban.summary.field`,
167-
* `columns[].prefix.field`). These reach no door this card measured. A
166+
* `fieldOrder`, `columns[].summary.field`, `kanban.summary.field`,
167+
* `columns[].prefix.field`, and `grouping.fields` on every kind but a
168+
* grid). These reach no door this card measured. A
168169
* dotted name at one of them is very likely still wrong — the gantt
169170
* scalars, for instance, read `record[startDateField]` flat — but "likely
170171
* wrong" is not the verdict a gate may invent (ADR-0072 D1), and the
171172
* failure would be the SILENT class rather than this loud one. Recorded as
172-
* a follow-up rather than guessed at here.
173+
* a follow-up rather than guessed at here. [#38654] A grid's
174+
* `grouping.fields[].field` was measured since: it reaches the aggregate
175+
* door, and is judged in its own section below.
173176
*
174177
* `sort[]` keeps its owner: `validate-sortable-fields.ts` records that it
175178
* "deliberately does not add a third finding" for a dotted name because the
@@ -360,7 +363,29 @@
360363
* ({@link LIST_VIEW_FIELD_UNKNOWN}), and a dotted name — the engine refuses
361364
* every dotted `groupBy` name on its own ground (a path, whatever the head
362365
* or the leaf), not by the storage class of the field it ends on, so this
363-
* verdict does not speak for it.
366+
* verdict does not speak for it: the next section does.
367+
*
368+
* ## [#38654] A dotted `grouping.fields[].field` on a grid
369+
*
370+
* {@link LIST_VIEW_FIELD_DOTTED}, `error`, on the same kinds as the section
371+
* above ({@link groupingReachesAggregate}). `engine.aggregate` refuses a
372+
* `groupBy` entry naming a dotted name the object does not declare verbatim
373+
* (`assertGroupByTargetsAreStored`, `400 INVALID_FIELD`), whatever its head or
374+
* its leaf: a group key is one of the object's own columns by its bare name,
375+
* 0 hops deep, and the header query compiles no join. The verdict asks that
376+
* same condition, so `account.name` and `account.tags` are refused alike.
377+
* Judged where the head resolves; a head that resolves to nothing is
378+
* {@link LIST_VIEW_FIELD_UNKNOWN}. The fix line reads the head as the engine's
379+
* message does: a single-valued relation head can be grouped by itself, one
380+
* group per related record. Every other kind keeps its grouping unjudged for
381+
* a dotted name, because no door fails its view: a kanban board with a
382+
* swimlane does send `grouping.fields[0]` in its one grouped count read
383+
* (`queryGroupHeaders`, when its counts are windowed), but the refusal is
384+
* absorbed and the board keeps its page counts; the board and the gallery
385+
* then read the name as a FLAT key of the fetched row (`card[swimlaneField]`,
386+
* `item[field]`), walking no path, so a dotted name groups nothing rather than
387+
* failing; calendar, timeline, gantt and map do not read grouping. That is
388+
* the silent class the renderer-binding note above leaves to a follow-up.
364389
*
365390
* ## [#32449] `columns[].summary` — a function the aggregate door refuses
366391
*
@@ -1686,6 +1711,46 @@ export function validateListViewFieldRefs(
16861711
});
16871712
};
16881713

1714+
/**
1715+
* [#38654] A grid grouping level's dotted `field` — see the section of that
1716+
* name on this module. The engine's own condition (`assertGroupByTargetsAreStored`):
1717+
* a dotted name the object does not declare verbatim, refused whatever its
1718+
* head or leaf. Judged only where the head resolves: a head that resolves to
1719+
* nothing is already `list-view-field-unknown`, and an unjudgeable one stays
1720+
* unjudged.
1721+
*/
1722+
const checkGroupFieldDotted = (
1723+
written: string,
1724+
object: string,
1725+
where: string,
1726+
path: string,
1727+
subject: string,
1728+
): void => {
1729+
if (graph.get(object)?.names.has(written)) return;
1730+
const head = written.split('.')[0];
1731+
if (!head) return;
1732+
const verdict = resolveFieldPath(graph, object, head);
1733+
if (!verdict || verdict.kind !== 'ok') return;
1734+
// The engine's own reading of the head, for the remedy only: a
1735+
// single-valued relation can be grouped by itself, one group per related
1736+
// record; a multi-valued one cannot (`list-view-group-field-ungroupable`).
1737+
const meta = verdict.meta;
1738+
const relation = typeof meta?.type === 'string' && REFERENCE_VALUE_TYPES.has(meta.type);
1739+
const single = relation && !isMultiValueField({ type: meta?.type, multiple: meta?.multiple === true } as never);
1740+
findings.push({
1741+
severity: 'error',
1742+
rule: LIST_VIEW_FIELD_DOTTED,
1743+
where,
1744+
path,
1745+
message:
1746+
`${subject} "${written}" is a dotted path; the engine groups by the object's own fields by name, ` +
1747+
"so the grid's group header query answers 400 INVALID_FIELD and no group renders",
1748+
hint: single
1749+
? `Group by "${head}" itself (one group per related record), or denormalise the value onto "${object}" and name that`
1750+
: `Group by a stored single-valued field of "${object}", or denormalise the value onto "${object}" and name that`,
1751+
});
1752+
};
1753+
16891754
/**
16901755
* [#38433] One `grouping.fields[]` entry's `field` — see the section of that
16911756
* name on this module: a declared field `engine.aggregate` does not group by.
@@ -1700,7 +1765,11 @@ export function validateListViewFieldRefs(
17001765
): void => {
17011766
if (!groupingReachesAggregate(listView)) return;
17021767
const written = strName(entry.field);
1703-
if (!written || written.includes('.')) return;
1768+
if (!written) return;
1769+
if (written.includes('.')) {
1770+
checkGroupFieldDotted(written, object, where, path, subject);
1771+
return;
1772+
}
17041773
const verdict = resolveFieldPath(graph, object, written);
17051774
if (!verdict || verdict.kind !== 'ok') return;
17061775
const refused = groupByRefusedClass(verdict.meta);

0 commit comments

Comments
 (0)