Repository navigation
Description
Problem
The atlas-search Worker's two gated routes disagree on what an empty query is (pkgs/atlas-search/worker/src/index.ts @ def55ca):
POST /v1/searchnormalizes the query and rejects an empty result:const query = normalizeQuery(body.query); if (!query) return errorJson(400, "bad_request", "query must not be empty").GET /v1/cache/inspect(:98-111) guards only the raw parameter —const q = url.searchParams.get("query"); if (!q) return errorJson(400, …, "query parameter is required")(:102-103) — then normalizes (:104) and never re-checks. A whitespace-onlyquery(?query=%20%20%20) normalizes to""and is accepted: the Worker computes the canonical key for the empty query, resolves the per-query Durable Object for it, and calls its/inspectroute, returning200 {"key": …, "query": "", …}.
So the inspect route — documented as the metadata readback for a real cached query — instantiates/queries a Durable Object for a query that can never exist (the search route can never create an entry for ""), and returns a success envelope for a request its sibling route defines as a 400.
Evidence (verified this run, laptop @ def55ca)
Probe ~/git/fleet/probe-atlas-inspect/probe.ts imports the real src/index.ts (bun) with a stub QUERY_CACHE namespace that counts DO calls:
- control:
POST /v1/searchwith{"query":" "}→400 {"error":{"code":"bad_request","message":"query must not be empty"}} - control:
GET /v1/cache/inspectwith noquery→400 … "query parameter is required" - control:
GET /v1/cache/inspect?query=hello→200, DO called once - defect:
GET /v1/cache/inspect?query=%20%20%20→200 {"key":"4588f191…","query":"","exists":false}, DO called once — the empty-after-normalize query reached keying and the Durable Object instead of the 400 both sibling checks imply.
test/worker.test.ts has no empty-query case for either route (grep: no empty/must not be empty test; only a whitespace-normalization comment) — the search route's guard is itself unpinned, and the inspect route has neither guard nor test. Sibling surface: #6879 covers the POST route's null-body crash — a different defect in the same file; this is the inspect route's missing post-normalization check.
Why it matters
Route-contract consistency is what clients and audit tooling rely on: the same malformed input is a 400 on one route and a 200 with a fabricated cache key on the other. It also spends a Durable Object instantiation (constructor + SQL table creation in cache_do.ts) on a key that can never hold a legitimate entry, retained indefinitely per the v1 no-eviction design (#6788).
Acceptance criteria
-
GET /v1/cache/inspectwith a query that is empty afternormalizeQuery(whitespace-only, including tabs/newlines/NBSP-class whitespace the normalizer collapses) returns400 bad_request("query must not be empty", matching the search route's message) and does not call the Durable Object. - Missing
querykeeps returning400 "query parameter is required"; a real query's inspect response is unchanged. - A regression test in
test/worker.test.tscovers the whitespace-only inspect case (400, no DO interaction); adding the search route's whitespace-only case in the same test pins both routes' contract.
Activity
developing-today commentedon Nov 7, 2026
CODE-2186
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 7, 2026
🤖 Agent note · picked up
Merge pull request #6938 from developing-today/creator-b/6937-inspect…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · done