Repository navigation
Description
codedb-bridge: a null daemon response body crashes codedb_tree out of the handler (no JSON-RPC response is ever sent) and reads as a successful "null" result on the other tools
bin/codedb-bridge.mjs trusts the shape of the daemon's JSON body after
res.json():
- The error check uses optional chaining (
data?.error), so anullbody
passes it. - For
codedb_treethe result line dereferences the body directly:
String(data.tree ?? ''). With anullbody that is a rawTypeError.
The throw escapescallTooland thenhandle()(thetools/callcase
awaitscallToolwith no guard), and inmain()the dispatch chain's
.catch(() => settle())swallows it — so no JSON-RPC response is ever
written for that request id. The MCP client hangs until its own timeout
with no error anywhere; the bridge logs nothing. - For the JSON-kind tools (
codedb_search,codedb_hot,codedb_outline,
codedb_symbol,codedb_word,codedb_deps) anullbody instead
returns a successful result whose text is the literal string"null"—
a daemon malfunction presented to the caller as a normal (empty-looking)
answer.
Verified this run (laptop probe, verbatim origin/main @ ac0bf3e, file md5 84097d1a)
Probe ~/git/fleet/probe-codedb-null on the laptop: the real module
extracted byte-identical from origin/main, driven through the exported
createHandler with a stubbed fetchFn answering HTTP 200:
| Call | Daemon body | Result |
|---|---|---|
codedb_tree (control) |
{"tree":"x"} |
ok, text x |
codedb_tree |
null |
throws TypeError: Cannot read properties of null (reading 'tree') out of handle() → swallowed by main's catch → no response for the id |
codedb_search |
null |
success result, text "null" |
codedb_hot |
null |
success result, text "null" |
codedb_search max_results control |
{"results":[1,2]}, max_results: 1 |
ok, sliced to [1] |
codedb_outline |
"weird" (string body) |
success result, text "\"weird\"" — the daemon's wrong shape passed through as if it were an outline |
The shipped suite (bin/codedb-bridge.test.mjs, 13/13 passing on the same
tree) stubs only well-shaped object bodies and daemon errors; no case covers
a null or non-object 200 body.
Why it matters
The bridge is the per-session shim every MCP client uses to reach the shared
codedb daemon; its design contract (#3352, in the module header) is that
problems are reported by name, never silently dropped. A daemon that answers
200 with a null/wrong-shape body (a partial write, a version-skewed daemon, a
proxy in between) currently produces the two worst outcomes: an indefinite
client hang with zero diagnostics on codedb_tree — the tool the header
tells callers to use first — and plausible-looking "null" successes
everywhere else, which a caller reads as "no results" rather than "the
daemon is broken".
Distinct from #4191 (daemon fetch has no timeout — the fetch never
returning) and #4216 (unknown argument names silently dropped): this is the
response-body shape after a successful fetch. Dedup: searched open and
closed issues for codedb-bridge — no issue covers daemon response-body
shape validation.
Acceptance criteria
- A daemon 200 body that is
nullor not a plain object produces an
isErrortext result naming the route and the unexpected shape, for
every tool kind (tree and json) — never a thrown exception out of
handle(), never a successful"null"result. - Well-shaped bodies behave exactly as today (existing tests green,
slicing anddata.errorhandling unchanged). - New tests in
bin/codedb-bridge.test.mjscover at least: null body
forcodedb_tree, null body for one json-kind tool, and a non-object
(string) body — each asserting anisErrorresult, not a throw and
not a success. -
node --test bin/codedb-bridge.test.mjspasses.
Activity
developing-today commentedon Nov 7, 2026
CODE-2175
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
data?.errorcheck, thenString(data.tree ?? '')throws out of handle() for codedb_tree (main's catch swallows it, so no JSON-RPC response is ever sent for that id) and JSON-kind tools return a successful literal "null" result (evidence and probe in the issue body).Merge pull request #6918 from developing-today/creator-b/6917-codedb-…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · done