Skip to content

[finding] rest: import-runner.ts still builds three server-built findData literals in the undeclared wire dialect, through a query: any helper #16638

Description

@claude

What

#16337 retired the last server-built wire-dialect findData literals in packages/rest/src/rest-server.ts — all four now spell the canonical QueryAST, and the wireDialectQuery helper that cast the slot is gone. The same package's packages/rest/src/import-runner.ts still has three, and they are invisible to the compiler for a different reason.

Where

packages/rest/src/import-runner.ts:

const findArgsBase = (query: any) => ({          // line 360 — the erasure vehicle
  object: '',
  query,
  ...(environmentId ? { environmentId } : {}),
  ...(context ? { context } : {}),
});

...findArgsBase({ $filter: { [f]: display }, $top: 2 }),        // line 389, reference resolver
p.findData({ ...findArgsBase({ $filter: filter, $top: 2 }), object: objectName })   // line 431, duplicate probe
...findArgsBase({ $filter: { id: { $in: ids } }, $top: ids.length }),               // line 552, id recheck

Why this is a contract violation and not a style note

FindDataRequestSchema declares query: QuerySchema.optional() (packages/spec/src/api/protocol.zod.ts), and QuerySchema declares where / limit / offset / fields / orderBy / expand — it declares neither $filter nor $top. Those two are wire-only spellings, and the normalizer's own table calls them exactly that: "the wire-only spellings no schema declares" (WIRE_QUERY_ALIAS_SLOTS, packages/metadata-protocol/src/protocol.ts). A server-built literal has no transport to be liberal with — it is the server constructing its own query — so this is the same declared-vs-shipped mismatch #16337 was filed for, in the sibling file.

The reason nothing reddens is findArgsBase(query: any): the parameter is any, so the literal is type-checked by nothing at all and the undeclared keys cost no diagnostic. That is the same mechanism as the fourth literal #16337 found in rest-server.ts (loadImportJob, whose protocol handle was any) — a literal nobody could see, named by no card.

No behaviour is at stake

The aliases DO fold: $filter resolves to where and $top to limit by the spec's own RPC_QUERY_ALIAS_SLOTS, with the value moved verbatim, so these three calls reach engine.find with the same option bag a canonical literal would produce. This is a typing and one-dialect question, not a defect — which is why it is filed rather than folded into #16337, whose scope its card fixes to rest-server.ts.

Suggested shape

The mechanical rewrite is the one #16337 already applied four times: $filter to where, $top to limit, add the required object, and type findArgsBase's parameter as FindDataRequest['query'] (or drop the helper and annotate each literal ServerScopedDataRequest<FindDataRequest>) so the compiler holds the ground afterwards. The pin added by #16337 (packages/rest/src/rest-server-canonical-query-ast.test.ts) is keyed to rest-server.ts; widening its source census to cover import-runner.ts would close the class for the whole package.

Related


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions