Skip to content

Commit 86f2afe

Browse files
fix(metadata-protocol)!: refuse a searchFields override naming no field instead of reading it as absent (#27670)
domain:server#2 · os-sales · session_01L6bhgUCizoYWQVJWjhdR6F <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuPMZ8BHWtPf6nBTp51qSM64)_ Fixes #27484 Clause-②: no (narrowing) — the data doors (`GET /data/:object`, `POST /data/:object/query`, `GET /data/:object/export`, and every other caller of `findData`) refuse a `searchFields` value that names no field, which they answered 200 over the default search set before. Nothing is widened. Metadata-protocol: none Skills-docs: none — `skills/objectstack-query/SKILL.md` already teaches "Omit it to search the object's declared `searchableFields`", and no skill emits an empty override; the two docs pages that list the search refusals are updated here (`content/docs/api/data-api.mdx`, `content/docs/data-modeling/queries.mdx`). ## 维护者速读 - **改了什么**:查询里写了 `$searchFields` 却一个字段都没给(空串、只有逗号、空数组,或对象形 `search.fields` 为空)时,数据接口现在回 400 `VALIDATION_ERROR` 并点名参数,跟 `$select=` 一样;导出接口同样拒收。 - **为什么改**:以前这种值被当成“没写”,搜索悄悄扫了对象的全部默认搜索字段,调用方本想收窄范围,结果拿到更宽的结果,界面上看不出任何异常。 - **风险与回滚**:只影响发了空 `searchFields` 的 API 调用方(Console 与自带视图插件都只在至少有一个字段时才发);引擎直接调用不变。回滚 = revert 本 PR。 - **先看**:`packages/metadata-protocol/src/protocol-query-validation.ts`(拒收那一段)、`packages/rest/src/data-action-routes.ts`(export 不再把空值当缺省)、`packages/objectql/src/query-expression-conformance.test.ts`(有意翻转的钉子)。 - **两分钟验证**:`pnpm --filter @objectstack/rest exec vitest run src/data-empty-search-fields-door.test.ts`,预期 4 个用例全过(列表、POST、导出三个门回 400,对照组照旧)。 - **需要你做的**:无,席位落地(进队前欠一次契约复核)。 ## What changes - **`assertSearchFieldsAreSearchable`** (`metadata-protocol/src/protocol-query-validation.ts`): an override that names no field used to `return` (read as ABSENT); it now throws `400 VALIDATION_ERROR` with `param` set to the caller's spelling and the message `Query parameter 'PARAM' names no field; got VALUE. …` — the envelope `projectionFieldsValue` gives `$select` (#26644). It covers the standalone slot in every spelling (`$searchFields`, `searchFields`, string or array) and the object-form `search.fields`, because the gate is the one place both reach. It runs before the field-map lookup, so a registry-less host refuses too. Absent stays absent: the door calls the gate only when a value was sent. On the list and query doors the refusal holds with or without a `search` term: `GET /data/:object?$searchFields=` alone answered 200 before and is 400 now, as a non-empty override naming an unknown field already was; the export route alone still ignores `searchFields` sent without `search`. - **`quotedQueryValue`** (`metadata-protocol/src/protocol.ts`): exported from the module (not from the package index) so the gate quotes the refused value exactly as the projection refusal does. One word in the hot file, beside `projectionFieldsValue`; no other line of `protocol.ts` moves. - **Export route** (`rest/src/data-action-routes.ts`): `searchFields=` and `searchFields=,` are kept as the empty list instead of being dropped, so `findData`'s gate refuses them on this route too. The route still ignores `searchFields` sent without `search`, as before. - **Two pins flipped on purpose** (triage ruling 6500648325, option A): - `objectql/src/query-expression-conformance.test.ts` — "an empty override is ABSENT, not malformed" becomes "an override naming no field is refused, not read as absent": `''`, `','`, `' , '`, `[]`, `$searchFields: ''`, and object-form `fields: []` / `''` each answer `400 VALIDATION_ERROR` naming the slot; a search with no override still answers the default scan. - `objectql/src/engine-search-empty-set.test.ts` — the junction leg `{ search: 'Dune', searchFields: '' }` now asserts the door's refusal (`VALIDATION_ERROR`, `param: 'searchFields'`) and keeps its point: no `lib_loan` read, so no silent widening to every row. The other two legs still assert the engine's junction refusal unchanged. - Why both flip: both pins drive `ObjectStackProtocolImplementation#findData`, the same door `GET /data/:object` hands `req.query` to, so refusing at that door and keeping them could not both hold (dev report 6499580381, ruling 6500648325). - **New door pin** `rest/src/data-empty-search-fields-door.test.ts`: real `RestServer` → `findData` → `ObjectQL` → sqlite. GET list (`$searchFields=`, `=,`, `= , `, unprefixed `searchFields=`), POST query (`searchFields: []`, object-form `fields: []`) and the csv export (`searchFields=`, `=,`) each answer 400 `VALIDATION_ERROR` naming the spelling, with zero reads of the object; controls (named override narrows, absent scans the default set, on all three doors) unchanged. - Docs: the refusal table in `content/docs/api/data-api.mdx` and the search callout in `content/docs/data-modeling/queries.mdx` name the new answer. - Changeset `.changeset/27484-blank-search-fields-refused.md` (`patch` on `@objectstack/metadata-protocol` and `@objectstack/rest`, BREAKING banner, ADR-0087 `not-required`). ## Tests Head `f0e6671a` (merge of `origin/main` b761968 onto `e995818e`); the full package runs and the dogfood battery ran on `e995818e`, the same diff before the merge. <details><summary>Package suites and typecheck (e995818)</summary> - `pnpm --filter @objectstack/metadata-protocol test` :: exit 0 · Test Files 279 passed, 4 skipped (283) · Tests 21781 passed, 26 skipped - `pnpm --filter @objectstack/objectql test` :: exit 0 · Test Files 487 passed (487) · Tests 9149 passed - `pnpm --filter @objectstack/rest test` :: exit 0 · Test Files 336 passed (336) · Tests 6591 passed, 326 skipped - `pnpm --filter PKG typecheck` for each of the three :: exit 0 (×3) - `pnpm lint` :: exit 0 </details> <details><summary>Re-run on the merged head f0e6671</summary> - rebuilt `metadata-protocol`, `objectql`, `rest`; `query-expression-conformance.test.ts` + `engine-search-empty-set.test.ts`: 207/207; `data-empty-search-fields-door.test.ts` + `export-integration.test.ts` + `data-empty-projection-count-door.test.ts`: 35/35; `pnpm --filter @objectstack/metadata-protocol test`: 21781 passed, 26 skipped. </details> <details><summary>Ablation (both legs red, then restored to the HEAD blob)</summary> - Gate leg: `node scripts/ablation-replace.mjs --file packages/metadata-protocol/src/protocol-query-validation.ts --anchor ' if (names.length === 0) {' --replacement " if ((globalThis as any).ABLATE_27484 === 'refuse' && names.length === 0) {"` — anchor 1 → 0, blob 1d6fa7d → 1e8d9b9a; rebuilt; `ablation-dist-preflight.mjs @objectstack/metadata-protocol ABLATE_27484` hit in `dist/index.js` and `dist/index.cjs`. Red: `query-expression-conformance` "an override naming no field is refused" (promise resolved instead of rejecting), `engine-search-empty-set` junction leg (got the engine's `has no searchable` refusal instead of `VALIDATION_ERROR`), and 3 of 4 in `data-empty-search-fields-door.test.ts` (GET list, POST query, export each answered 200 with all 3 rows). Restored: blob after == HEAD 1d6fa7d, `git diff HEAD` empty; rebuilt; preflight `--absent` clean over 24 built files, tree clean. - Export leg (gate intact): `--file packages/rest/src/data-action-routes.ts --anchor " if (typeof q.searchFields === 'string') {"` → the old `q.searchFields.length > 0` guard. Red: the export case only (`searchFields=""` answered 200); GET/POST/control stayed green. Restored: blob == HEAD 87b3e97, `git diff HEAD` empty. </details> <details><summary>Dogfood battery (e995818)</summary> `pnpm exec turbo run build --filter='@objectstack/dogfood^...'` then `pnpm --filter @objectstack/dogfood test` under `os-verify-lock.sh`, no shard, no path: `VERDICT command-exit 0` · Test Files 351 passed, 3 skipped (354) · Tests 2822 passed, 20 skipped (2842) · no failures. </details> ## Acceptance notes - Branch `claude/project-thread-jmw8xb` is the card thread's harness-pinned branch, named in claim 6499488942; it carries no issue number. - The export route's json format writes its opening `[` before the first `findData`, so a `findData` refusal there (this one, and the existing `searchFields=nope` one) lands as a truncated json stream rather than a clean 400; csv and xlsx answer the envelope. Not changed here; filed as #27682. - The published declarations still admit the value this door refuses: `QueryTransportParamsSchema.$searchFields`, `EngineQueryOptionsSchema.searchFields`, `QuerySchema.searchFields` and `FullTextSearchSchema.fields` accept `''` and `[]`. So on `POST /data/:object/query` the sibling `select: []` is the body schema's `400 VALIDATION_FAILED` while `searchFields: []` is the gate's `400 VALIDATION_ERROR`. Narrowing the declarations (and the engine question) is follow-up #27683. - `engine.find()` / `engine.count()` called directly still read an empty `searchFields` as absent (the engine posture; `protocol-record-reads.ts`'s palette sweep never sends an empty one). - Producers checked: `ui/packages/data-objectstack`, `plugin-list` `ListView.tsx`, `plugin-kanban`, `plugin-gantt` all send `$searchFields` / `searchFields` only when the list has at least one entry. - Hot file: the only open PR touching `metadata-protocol/src/protocol.ts` is #27535; `git merge-tree --write-tree HEAD` against its head 585e619 is clean. No open PR touches the other changed files. ## Verification Local subset, head `f0e6671a`: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 93 families; every one run with its exit code captured before any pipe, all 93 `exit 0` (`check:type-check-debt` under `os-verify-lock.sh`). `--ran` reconcile: "93 derived, 93 run, 0 NOT-MEASURED, 0 UNRUN". The same 93 were also all `exit 0` on `e995818e` before the merge. Two families answered exit 3 on the first pass and were re-run after their prerequisite, not read as a verdict: `check-plugin-teardown-shape.mjs --self-test` (pinned fixture commit fetched) and `check:dual-build-cjs-loads` / `spec check:skill-examples` (seven dists built). CI-run families: see this PR's check-runs. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the maintainer summary block is the dispatch contract's Chinese section). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgTgHg75Rd5XFiwbUZh)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgTgHg75Rd5XFiwbUZh --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 69991ff commit 86f2afe

9 files changed

Lines changed: 287 additions & 20 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
'@objectstack/rest': patch
4+
---
5+
6+
fix(metadata-protocol)!: a `searchFields` override naming no field (`$searchFields=`, `$searchFields=,`, `[]`) is refused 400, not read as absent, so a narrowed search no longer runs over the default search fields (#27484)
7+
8+
Clause-②: no (narrowing) — the data doors (`GET /data/:object`, `POST /data/:object/query`, `GET /data/:object/export`, and every other caller of `findData`) refuse a `searchFields` value that names no field, which they answered 200 over the default search set before. Nothing is widened.
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type changes: a query value that names no field is refused where it was read as absent. The fix for a caller is to send a field name or leave the parameter out, which the refusal says; there is nothing for a migration to rewrite and no tombstone. -->
12+
13+
**BREAKING** accept-set narrowing at the query door (`@objectstack/metadata-protocol`), served by every Data API door.
14+
15+
- **Before.** A blank or comma-only `$searchFields` (or `searchFields`), an empty array, or an empty object-form `search.fields` was read as no override, and the search scanned the object's whole default search set: `?$search=initech&$searchFields=` answered the rows `?$search=initech&$searchFields=industry` excludes, under a 200. The export route dropped a blank `searchFields` itself before the query ran.
16+
- **Now.** `400 VALIDATION_ERROR`, naming the parameter the caller wrote (`Query parameter '$searchFields' names no field`), the envelope `$select` answers for a projection naming no field (#26644). No row is read. On the list and query doors this holds with or without a `search` term: `?$searchFields=` alone is refused too, as a non-empty override naming an unknown field already is.
17+
- **Unchanged.** An absent `searchFields` searches the default set; a named one narrows it; a name outside the searchable set is still `400 INVALID_FIELD`. The engine (`find` / `count` called directly) still reads an empty override as absent. The export route still ignores `searchFields` sent without `search`.
18+
- **Not yet narrowed.** The published declarations (`QueryTransportParamsSchema.$searchFields`, `EngineQueryOptionsSchema.searchFields`, `QuerySchema.searchFields`, `FullTextSearchSchema.fields`) still admit `''` and `[]`; the refusal is the door's. So on `POST /data/:object/query` the sibling `select: []` is the body schema's `400 VALIDATION_FAILED` while `searchFields: []` is this `400 VALIDATION_ERROR`. Narrowing the declarations is follow-up #27683.
19+
- **Who sees it.** An API caller that sends `searchFields` with no field in it. The Console and the bundled view plugins send the parameter only when it holds at least one field.
20+
21+
**The remedy.** Leave the parameter out to search the default fields, or name the fields to search.

‎content/docs/api/data-api.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ corrupts something the earlier axes do not:
154154
|:---|:---|
155155
| `?search=alpha&searchFields=title` | scans only `title` |
156156
| `?search=alpha&searchFields=no_such_field` | `400 INVALID_FIELD` |
157+
| `?search=alpha&searchFields=` (or `=,`, or `[]` in a body) | `400 VALIDATION_ERROR` — names no field, the answer `$select=` gets; leave the parameter out to scan the default set |
157158
| `?search=alpha&searchFields=amount` | `400 INVALID_FIELD` — real field, but not searchable |
158159
| `?search=alpha&searchFields=project_id.name` | `400 INVALID_FIELD` — search scans this object's own columns; mirror the related title instead (see below) |
159160
| `?search=alpha` on an object with no searchable field (two lookups and a `formula` title, say) | `400 INVALID_FIELD` — nothing to scan; declare a stored field searchable or mirror the title (see below) |

‎content/docs/data-modeling/queries.mdx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,12 @@ Only `query` and `fields` are implemented. The engine expands `search` into a dr
540540
**narrow** the scan within the server-resolved searchable set — the object's declared
541541
`searchableFields`, or a text-like auto-default when none are declared. Over the
542542
REST/protocol ingress a name outside that set is `400 INVALID_FIELD`, with distinct
543-
messages for a field that does not exist and a real field that is not searchable. The
544-
engine used to drop unknown names and fall back to the full searchable set — a parameter
545-
that exists to narrow a search, silently widening it. Internal callers reaching
546-
`engine.find()` directly are unaffected.
543+
messages for a field that does not exist and a real field that is not searchable. An
544+
override that names no field at all (`?$searchFields=`, `?$searchFields=,`, an empty
545+
array) is `400 VALIDATION_ERROR`, as `$select=` is; leave the parameter out to scan the
546+
default set. The engine used to drop unknown names and fall back to the full searchable
547+
set — a parameter that exists to narrow a search, silently widening it. Internal callers
548+
reaching `engine.find()` directly are unaffected.
547549
</Callout>
548550

549551
### Searching by a related record's title — mirror the value

‎packages/metadata-protocol/src/protocol-query-validation.ts‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444

4545
import type { ObjectStackProtocolImplementation } from './protocol.js';
46-
import { FILTER_LOGICAL_KEYS, ODATA_SPELLING, QUERY_PARAM_NEAR_MISS, collectFilterReads, invalidSortError, isObjectOfDisabledPackage, isPlainRecord, nearMissKey, objectPackageDisabledError, suggestFieldName } from './protocol.js';
46+
import { FILTER_LOGICAL_KEYS, ODATA_SPELLING, QUERY_PARAM_NEAR_MISS, collectFilterReads, invalidSortError, isObjectOfDisabledPackage, isPlainRecord, nearMissKey, objectPackageDisabledError, quotedQueryValue, suggestFieldName } from './protocol.js';
4747
import { objectNotFoundError, relationConditionSites } from '@objectstack/core';
4848
import { collectInternalWriteResponseFields } from './write-response-internal-fields.js';
4949
import { AggregationFunction, DateGranularity, REFERENCE_VALUE_TYPES, SEARCHABLE_ENUM_TYPES, SEARCHABLE_TEXTUAL_TYPES, SEARCH_AUTO_EXCLUDED_FIELDS, apiExposureDenialReason, canServeApiOperation, classifyDottedFilterHead, effectiveOperationsArray, isFilterAST, isVirtualSearchField, parseFilterAST, referenceTargetOf, resolveEffectiveApiMethods, resolveSearchFieldResolution } from '@objectstack/spec/data';
@@ -874,10 +874,26 @@ export function assertSearchFieldsAreSearchable(
874874
err.param = param;
875875
throw err;
876876
}
877-
// An empty override is ABSENT — the engine falls through to the
878-
// allowed set for it, which for a caller who named nothing is the
879-
// answer they asked for, not a widened one.
880-
if (names.length === 0) return;
877+
// [#27484] …and an override naming NO field is refused, not read as
878+
// absent. A blank or comma-only string, an empty array, or an empty
879+
// object-form `search.fields` used to return here, and the engine then
880+
// scanned the object's whole default set: a caller who wrote the
881+
// parameter meant to narrow, so its silent widening to the defaults is
882+
// the failure this gate exists for. Absent stays absent (the caller
883+
// passes no override, and the door never calls this gate). The
884+
// projection's envelope (`projectionFieldsValue`, #26644), so `$select`
885+
// and `$searchFields` answer a value naming no field alike.
886+
if (names.length === 0) {
887+
const err: any = new Error(
888+
`Query parameter '${param}' names no field; got ${quotedQueryValue(requested)}. The query was not `
889+
+ "run: an empty search-field list was read as no narrowing, which scans the object's default "
890+
+ 'search fields. Name at least one field, or leave the parameter out to search the default fields.',
891+
);
892+
err.status = 400;
893+
err.code = 'VALIDATION_ERROR';
894+
err.param = param;
895+
throw err;
896+
}
881897
const gate = this.resolveQueryFields(object);
882898
if (!gate) return;
883899
// [#22646] A field declared `internal: true` is never a search target,

‎packages/metadata-protocol/src/protocol.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,9 +4641,11 @@ function pageWindowValue(value: unknown, param: string): number {
46414641
/**
46424642
* A refused query value as the refusal quotes it: JSON, so a blank or
46434643
* whitespace-only value is visible, and bounded, so a long one cannot bury
4644-
* the sentence around it.
4644+
* the sentence around it. [#27484] Exported for the search-fields gate
4645+
* (`protocol-query-validation.ts`), which refuses an empty override in the
4646+
* projection's words.
46454647
*/
4646-
function quotedQueryValue(value: unknown): string {
4648+
export function quotedQueryValue(value: unknown): string {
46474649
// `String` for a number: `JSON.stringify(Infinity)` is `null`.
46484650
const shown = typeof value === 'number' ? String(value) : JSON.stringify(value) ?? String(value);
46494651
return shown.length > 64 ? `${shown.slice(0, 64)}…` : shown;

‎packages/objectql/src/engine-search-empty-set.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,19 @@ describe('[#24284] the palette keeps its skip; the data door surfaces the refusa
226226

227227
it('findData over the junction answers the refusal, on the list and the query shapes', async () => {
228228
const { protocol, reads } = await makeHarness();
229-
for (const query of [{ search: 'zzzz-nothing' }, { search: 'Dune', searchFields: '' }, { search: { query: 'Dune' } }]) {
229+
for (const query of [{ search: 'zzzz-nothing' }, { search: { query: 'Dune' } }]) {
230230
const err: any = await (protocol as any).findData({ object: 'lib_loan', query }).then(() => null, (e: any) => e);
231231
expect(err, JSON.stringify(query)).toMatchObject(REFUSAL);
232232
}
233+
// [#27484] Flipped on purpose (triage ruling 6500648325, option A): a
234+
// blank override no longer reaches the engine as "absent", so the door
235+
// refuses it first, in the projection's envelope. The point of this
236+
// leg holds: a search over the junction never silently widens to every
237+
// row; no `lib_loan` read is made on either refusal.
238+
const blankOverride: any = await (protocol as any).findData({
239+
object: 'lib_loan', query: { search: 'Dune', searchFields: '' },
240+
}).then(() => null, (e: any) => e);
241+
expect(blankOverride).toMatchObject({ code: 'VALIDATION_ERROR', status: 400, param: 'searchFields' });
233242
expect(reads.filter((r) => r.object === 'lib_loan')).toEqual([]);
234243
// …and the control object and the blank term are untouched.
235244
const book: any = await (protocol as any).findData({ object: 'lib_book', query: { search: 'Dune' } });

‎packages/objectql/src/query-expression-conformance.test.ts‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,12 +2271,29 @@ describe('#4254 — searchFields / groupBy / aggregations on the list path (real
22712271
})).rejects.toThrow(/scans this object's own columns/);
22722272
});
22732273

2274-
it('an empty override is ABSENT, not malformed', async () => {
2275-
for (const searchFields of ['', []]) {
2276-
expect(titles(await protocol.findData({
2277-
object: 'showcase_task', query: { search: 'a', searchFields },
2278-
}))).toEqual(['A', 'B']);
2274+
// [#27484] Flipped on purpose (triage ruling 6500648325, option A). This
2275+
// pin read an empty override as ABSENT; the door now refuses it in the
2276+
// projection's envelope (#26644), as `$select` refuses a projection naming
2277+
// no field. Read as absent, the search scanned the default set: a caller who
2278+
// wrote the parameter meant to narrow, and got the widest scan instead.
2279+
it('an override naming no field is refused, not read as absent', async () => {
2280+
const named = [
2281+
[{ searchFields: '' }, 'searchFields'],
2282+
[{ searchFields: ',' }, 'searchFields'],
2283+
[{ searchFields: ' , ' }, 'searchFields'],
2284+
[{ searchFields: [] }, 'searchFields'],
2285+
[{ $searchFields: '' }, '$searchFields'],
2286+
[{ search: { query: 'a', fields: [] } }, 'search'],
2287+
[{ search: { query: 'a', fields: '' } }, 'search'],
2288+
] as const;
2289+
for (const [query, param] of named) {
2290+
await expect(protocol.findData({
2291+
object: 'showcase_task', query: { search: 'a', ...query },
2292+
}), JSON.stringify(query)).rejects.toMatchObject({ status: 400, code: 'VALIDATION_ERROR', param });
22792293
}
2294+
// …and a search with no override at all is untouched: absent is absent.
2295+
expect(titles(await protocol.findData({ object: 'showcase_task', query: { search: 'a' } })))
2296+
.toEqual(['A', 'B']);
22802297
});
22812298

22822299
// ─────────────────────────────────────────────────────────────

‎packages/rest/src/data-action-routes.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,14 +1190,20 @@ export function registerDataActionEndpoints(this: DataActionRouteHost, basePath:
11901190
? q.search.trim()
11911191
: undefined;
11921192
// ADR-0061 override for which fields the term scans. Only meaningful
1193-
// alongside `search`; ignored on its own, exactly as in findData.
1193+
// alongside `search`; ignored on its own.
1194+
//
1195+
// [#27484] A value naming no field (`searchFields=`, `=,`) is
1196+
// kept as the empty list rather than read as absent, so
1197+
// `findData`'s search-fields gate refuses it exactly as on the
1198+
// list door. Read as absent, the export scanned the object's
1199+
// default search fields: a file of rows the caller's narrowing
1200+
// excluded.
11941201
let searchFields: string[] | undefined;
1195-
if (typeof q.searchFields === 'string' && q.searchFields.length > 0) {
1202+
if (typeof q.searchFields === 'string') {
11961203
searchFields = q.searchFields.split(',').map((s: string) => s.trim()).filter(Boolean);
11971204
} else if (Array.isArray(q.searchFields)) {
11981205
searchFields = q.searchFields.filter((s: any) => typeof s === 'string' && s.length > 0);
11991206
}
1200-
if (searchFields && searchFields.length === 0) searchFields = undefined;
12011207

12021208
let orderby: any = undefined;
12031209
if (typeof q.orderby === 'string' && q.orderby.length > 0) {

0 commit comments

Comments
 (0)