Skip to content

codedb-bridge: null daemon response body crashes codedb_tree out of the handler (no JSON-RPC response sent) and reads as a successful "null" result on other tools #6917

Closed

Description

@dezren39

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 a null body
    passes it.
  • For codedb_tree the result line dereferences the body directly:
    String(data.tree ?? ''). With a null body that is a raw TypeError.
    The throw escapes callTool and then handle() (the tools/call case
    awaits callTool with no guard), and in main() 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) a null body 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 null or not a plain object produces an
    isError text 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 and data.error handling unchanged).
  • New tests in bin/codedb-bridge.test.mjs cover at least: null body
    for codedb_tree, null body for one json-kind tool, and a non-object
    (string) body — each asserting an isError result, not a throw and
    not a success.
  • node --test bin/codedb-bridge.test.mjs passes.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    effort/xsTrivial: expected under 30 minutes of work
    app/codedb-bridgebin/codedb-bridge.mjs — stdio MCP bridge to the shared codedb daemon
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-07T16:20Z
    • Found via: filed this run
    • Task: Validate the codedb daemon's response-body shape in codedb-bridge — a null 200 body passes the data?.error check, then String(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).
    • Expectation: effort/xs — done when a null/non-object daemon body yields an isError result naming the route and shape for every tool kind, well-shaped bodies are unchanged, and regression tests pin the null-tree / null-json / string-body cases. Taken as a guarded self-solve this run (trivial, clearly scoped, low-risk).
    • Links: probe ~/git/fleet/probe-codedb-null (laptop); self-solve branch creator-b/6917-codedb-null-body
  5. added a commit that references this issue on Nov 7, 2026
  6. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-07T16:20Z
    • Found via: filed this run
    • Result: Fixed and merged this run — PR codedb-bridge: null/non-object daemon body is an isError result (#6917) #6918 merged 84890c3 (branch creator-b/6917-codedb-null-body, commit f619bca). After the existing HTTP/error handling, a daemon body that is null, an array, or not an object now returns an isError result naming the daemon, route, and unexpected shape, for every tool kind.
    • Verification: laptop probe against the fixed module — null tree / null search / null hot / string outline bodies all return isError results naming route and shape (pre-fix: tree threw out of handle() with no response ever sent; the others returned a successful literal "null"); well-shaped controls unchanged. Suite 14/14 on the branch and 14/14 again on merged main @ 84890c3.
    • Links: probe ~/git/fleet/probe-codedb-null (laptop); PR codedb-bridge: null/non-object daemon body is an isError result (#6917) #6918
  7. added and removed
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/codedb-bridgebin/codedb-bridge.mjs — stdio MCP bridge to the shared codedb daemoneffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus/donestatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions