Files
coder/coderd
49cd380e67 test(coderd/x/chatd): ignore non-hook requests in hook consumers (#32277)
`TestPreToolUseHookAllow/passthrough` failed in CI
([job](https://github.com/coder/coder/actions/runs/43909622615/job/133447870881))
because its hook consumer received five requests with empty bodies:
`json.NewDecoder(r.Body).Decode` returned `EOF` each time. Every real
hook delivery in the test succeeded, and its other assertions passed.

The dispatcher only sends POSTs with a non-empty JSON body and an
`Authorization: Bearer` token, so those requests did not come from this
test's dispatcher. The likely source is port reuse. The package's tests
run in parallel, and a closed `httptest` server's port can be handed to
a new server while another test's client (for example an MCP
streamable-HTTP client reconnecting its GET stream) is still retrying
it. The logs don't show which client sent them.

The hook consumers in the chatd tests now answer anything that is not a
POST with a bearer token with 404, instead of failing the test while
decoding it. This uses a shared `isHookRequest` helper.
`TestHookDispatcherRequiresExperiment`, which asserts the consumer gets
no hook requests, now counts only hook deliveries.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01VpiVZBgFqiSdRKrH8dPSPT)_

Co-authored-by: Garrett <garrett@coder.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:47:45 +02:00
..