Skip to content

Commit a0b28e1

Browse files
committed
test(runtime): cast search's route-less discovery record, add changeset (#7939)
TS2339 on info.services.search.route: svcInProcess()'s return type carries no route key at all, matching the same cast the #4318 cache/queue/job tests already use. Re-measured @objectstack/runtime's TEST_DEBT at 227 (recorded), unchanged.
1 parent a42af3b commit a0b28e1

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
"@objectstack/runtime": patch
3+
---
4+
5+
fix(runtime): discovery no longer claims a bound handler for the `search` slot (#7939)
6+
7+
`getDiscoveryInfo()`'s `services.search` entry reported `handlerReady: true` for
8+
any registered search-service occupant that carries no `__serviceInfo`
9+
self-description — even though the dispatcher has no `/search` route or handler
10+
at all (no `route-ledger.ts` entry, no branch in `http-dispatcher.ts`). That
11+
contradicted the map's own stated contract: `handlerReady: true` means "the
12+
dispatcher has a real, bound handler for this route."
13+
14+
This is the same contradiction #4318 closed for `cache`/`queue`/`job`, applied
15+
to the one slot of that shape it did not reach. `search` now uses the same
16+
`svcInProcess()` remedy, reporting `handlerReady: false` for a filled slot —
17+
with its own message rather than the shared "Kernel-internal service" wording,
18+
since a registered search service is an external engine (Elasticsearch/
19+
Meilisearch), not a kernel-managed in-process contract.
20+
21+
`capabilities.search` (the host's `/search` HTTP surface, fixed separately in
22+
#7602 / PR #7937) is untouched — this only corrects `services.search`, which
23+
describes what is *registered*, not what is served.
24+
25+
Latent until now: nothing registers an `ISearchService` in either repository
26+
(`CORE_SERVICE_PROVIDER['search']` is `null`), so the wrong branch was never
27+
reachable in practice. Covered by two new fixture-filled tests that register a
28+
search occupant before asserting `handlerReady`, since an empty-slot test would
29+
pass regardless of what the line says.

packages/runtime/src/http-dispatcher.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3043,7 +3043,11 @@ describe('HttpDispatcher', () => {
30433043
(kernel as any).services = new Map([['search', searchSvc]]);
30443044

30453045
const info = await dispatcher.getDiscoveryInfo('/api/v1');
3046-
const reported = info.services.search;
3046+
// Cast like the #4318 cache/queue/job tests above: `svcInProcess`'s
3047+
// return type carries no `route` key at all (route-less by
3048+
// construction), so a direct `info.services.search.route` read
3049+
// does not typecheck against the narrowed union.
3050+
const reported = (info.services as Record<string, any>).search;
30473051
expect(reported.enabled, 'services.search.enabled').toBe(true);
30483052
expect(reported.status, 'services.search.status').toBe('available');
30493053
expect(reported.handlerReady, 'services.search.handlerReady').toBe(false);

0 commit comments

Comments
 (0)