Skip to content

Commit 887e562

Browse files
committed
fix(lint): searchable targets read names off the served objects, so an all-tied object still refuses an unknown entry (#30608)
A searchable target built from the tie-dropped objects was null when every served field was tied, which turned the existence check off. Names now come from the served objects with ties kept, and the tied metas are blanked afterwards. The changeset also records two moves the review measured: a flow variable named after an extension-added trigger field is an ambiguous root, and an extended owner's legacy array fields are known names to form layout. Claude-Session: https://claude.ai/code/session_01L6bhgVSM5tJd2UYk3Aa1MM Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2818af5 commit 887e562

3 files changed

Lines changed: 44 additions & 9 deletions

File tree

‎.changeset/30608-remaining-field-indexes-extension-fields.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Skills-docs: none — measured: no sentence in `skills/` or `content/docs/` stat
1919
- an owner field an extension re-declares: judged on the extension's type, `required`, or autonumber format (the rows the Clause-② line names), and the inverse re-declarations pass (an owner `file` field re-declared `text` on a public form, an owner lookup re-declared `text` in a template, an owner autonumber re-declared `text`);
2020
- an autonumber field an extension adds is checked as an owner's is;
2121
- a list view over an object that declares no field: `list-view-field-unknown` `error` → nothing, extended or not.
22+
- a flow variable bound to a record whose name is a field an `objectExtensions` entry adds to the trigger object: the record-triggered run flattens that field to top level too, so the variable is an ambiguous root and its holes are no longer judged (`flow-template-unknown-field` `warning` → nothing), as for a variable named after a declared trigger field;
23+
- a form section on an extended object whose owner declares `fields` in the legacy array shape: the owner's array fields are now known names, so `form-field-unknown` `warning` on them → nothing.
2224
- **Not judged.** A field two packages write at the same deciding priority is a served name, but no rule judges its type, `required` or autonumber format: which definition wins is registration order (a gallery page over an object carrying one is not reported). An object that declares no field of its own stays unjudged by the notify, public form, page visualization, searchable and autonumber rules and by the list-view rule, extended or not (an introspected schema). The form-layout and flow template rules judged such an object against the empty set before and still do, an extension's own names now known.
23-
- **Not changed.** Which extension entries the fold keeps, the runtime, the object-level reads (`external`, the injected anchors, an object's own list views and `searchableFields`), and the finding paths. A stack that names no extension field reads as before.
25+
- **Not changed.** Which extension entries the fold keeps, the runtime, the object-level reads (`external`, the injected anchors, an object's own list views and `searchableFields`), and the finding paths. A stack that names no extension field reads as before. A flow variable whose name no body declares or adds on the trigger object is judged as before. A form section on an object nothing extends reads only map-shaped `fields`, as before: its legacy array fields are still reported `form-field-unknown`.
2426

2527
**What an author does.** Fix the extension's field definition (type an email recipient `email`, keep a file field off a public form, give a gallery an image field, keep a search column stored, mark an autonumber scope field `required: true`) or the reference that names it.

‎packages/lint/src/object-graph.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,39 @@ describe('[#30608] the remaining field indexes read the objects as served', () =
13681368
for (const s of onLegs(stack, [ext(drawing), ext({})], objects)) expect(run(s).map((f) => f.rule)).toEqual([id]);
13691369
});
13701370

1371+
// Every served field tied (the owner declares only `title`, two packages
1372+
// re-declare it): the names still come from the served object, so an entry
1373+
// no body declares is refused as on `main`, in both registration orders,
1374+
// and the tied name itself is a served name with nothing judged on it.
1375+
it('searchable: an object whose every served field is tied still refuses an unknown entry', () => {
1376+
const titled = (more: Rec = {}) => ({ name: 'xs_deal', label: 'Deal', fields: { title: { type: 'text' } }, ...more });
1377+
const surfaces: Array<[string, (entry: string) => [Rec, unknown[]]]> = [
1378+
['object', (entry) => [{}, [titled({ searchableFields: [entry] }), account]]],
1379+
['list view', (entry) => [{
1380+
views: [{ name: 'vs', objectName: 'xs_deal', list: { type: 'grid', columns: ['title'], searchableFields: [entry] } }],
1381+
}, [titled(), account]]],
1382+
];
1383+
const a = { title: { type: 'text' } };
1384+
const b = { title: { type: 'formula', expression: 'record.title' } };
1385+
for (const [surface, build] of surfaces) {
1386+
const [unknown, unknownObjects] = build('nowhere');
1387+
const [known, knownObjects] = build('title');
1388+
for (const packages of [[ext(a), ext(b)], [ext(b), ext(a)]]) {
1389+
for (const s of onLegs(unknown, packages, unknownObjects)) {
1390+
expect(verdicts(validateSearchableFields, s), surface).toEqual([[SEARCHABLE_FIELD_UNKNOWN, 'error']]);
1391+
}
1392+
for (const s of onLegs(known, packages, knownObjects)) expect(verdicts(validateSearchableFields, s), surface).toEqual([]);
1393+
}
1394+
// Controls: unextended, the same refusal; one writer alone, judged on its definition.
1395+
for (const s of onLegs(unknown, [[]], unknownObjects)) {
1396+
expect(verdicts(validateSearchableFields, s), surface).toEqual([[SEARCHABLE_FIELD_UNKNOWN, 'error']]);
1397+
}
1398+
for (const s of onLegs(known, [ext(b), ext({})], knownObjects)) {
1399+
expect(validateSearchableFields(s).map((f) => f.rule), surface).toEqual([SEARCHABLE_FIELD_UNSEARCHABLE]);
1400+
}
1401+
}
1402+
});
1403+
13711404
// An object that declares no field (an introspected schema) is left
13721405
// unjudged where `main` skipped it: an extension adding to it does not make
13731406
// its other columns knowable, nor its added fields judgeable by these rules.

‎packages/lint/src/validate-searchable-fields.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ import {
158158
SEARCH_FLAG_EXCLUDED_TYPES,
159159
type SearchFieldMeta,
160160
} from '@objectstack/spec/data';
161-
import { objectsAsServed, objectsWithoutTiedFields, recordsOf, suggestName } from './object-graph.js';
161+
import { objectsAsServed, recordsOf, suggestName } from './object-graph.js';
162162
import {
163163
SYSTEM_FIELDS,
164164
indexUnprovisionedAnchors,
@@ -360,8 +360,8 @@ export function indexObjectSearchTargets(
360360
* replaces the owner's whole (the registry's `mergeObjectDefinitions`).
361361
*
362362
* - The type, `hidden` and `searchable` meta are the field's definition, so a
363-
* field two packages tie on is left out of them
364-
* (`objectsWithoutTiedFields`) and kept as a name with a stub meta (`{}`),
363+
* field two packages tie on keeps its name (read off the served objects,
364+
* ties kept) and gets a stub meta (`{}`),
365365
* the way `resolveAllowedSet` stubs a system column: existence holds, the
366366
* virtual and credential checks have no type to read, and the auto-default
367367
* admissibility pass reads an unreadable type as unresolvable, not wrong.
@@ -376,14 +376,14 @@ export function indexServedSearchTargets(
376376
): Map<string, ObjectSearchTarget | null> {
377377
if (!isRec(stack)) return new Map();
378378
const served = objectsAsServed(stack);
379-
const out = indexObjectSearchTargets({ objects: objectsWithoutTiedFields(served) });
379+
// Names from the served objects, ties kept, THEN the tied metas blanked: a
380+
// target built from the tie-dropped objects is `null` when every served
381+
// field is tied, which would turn the existence check off.
382+
const out = indexObjectSearchTargets({ objects: served.objects });
380383
for (const [name, tiedKeys] of served.tied) {
381384
const target = out.get(name);
382385
if (!target) continue;
383-
for (const key of tiedKeys) {
384-
target.names.add(key);
385-
target.fields[key] = {};
386-
}
386+
for (const key of tiedKeys) target.fields[key] = {};
387387
}
388388
for (const [name, target] of indexObjectSearchTargets(stack)) {
389389
if (target === null) out.set(name, null);

0 commit comments

Comments
 (0)