Repository navigation
Description
Problem
The github-ci Worker (pkgs/github-ci/worker/src/index.ts, #5693) parses the webhook body and then dereferences it outside its error envelope:
let payload: Record<string, unknown>;
try {
payload = JSON.parse(raw);
} catch {
return new Response("bad json", { status: 400 });
}
...
const repo = (payload.repository ?? {}) as Record<string, unknown>;JSON.parse("null") succeeds and yields null, so a signed body of literally null passes the parse guard and then throws TypeError: null is not an object (evaluating 'payload.repository') at the payload.repository read — which sits before the try { ... } catch block that produces the worker's receiver failed: … 500 envelope. The exception escapes fetch entirely: Cloudflare returns its generic unhandled-exception 500, nothing is logged with the worker's event/repo context, and GitHub records a failed delivery it will retry — a poison delivery that can never succeed, for every event type (the deref happens before routing).
Other non-object JSON bodies survive only by accident of JS semantics: [], "str", and 123 box to objects with an undefined repository, land on repoName = "unknown", and exit through the normal skip/ignore paths. null is the one valid-JSON body that crashes — and it is exactly the case the shipped test suite does not cover (worker.test.ts posts objects only).
Evidence (verified this run, laptop @ 63f83be, probe ~/git/fleet/probe-ghci-snapshot)
Real pkgs/github-ci/worker/src/*.ts copied verbatim (md5-checked: index.ts 9b29537d…, sink.ts 487d63ee…) into the probe; worker.fetch driven directly with correctly HMAC-signed bodies (the probe signs with the same WebCrypto HMAC the worker verifies):
- Control — body
{}(eventworkflow_run, valid signature) → HTTP 200,{"ok":true,"skipped":"not_completed","repo":"unknown",…}. - Bug — body
null(eventworkflow_run, valid signature) →worker.fetchTHREWTypeError: null is not an object (evaluating 'payload.repository')— no Response at all. - Bug — body
null(eventpush, valid signature) → same throw (crash precedes routing). - Control — body
[](eventworkflow_run) → HTTP 200 skip path.
Why it matters
A webhook receiver's one job is to turn any delivered bytes into a deliberate HTTP answer. A body shape that escapes the handler as an unhandled exception defeats the worker's own failure envelope and logging, produces a retryable 500 for a delivery that can never succeed, and — because the throw happens before the event routing — takes down every event type at once, not just one route. It is also the shape most likely to be hit by a misconfigured sender or a probe, precisely when a clean 400 matters most.
Acceptance criteria
- A signed
nullJSON body (and any other non-object JSON body: array, string, number, boolean) gets a deliberate response — 400 is the natural choice — for every event type, with no exception escapingfetch. - Object bodies keep today's behavior byte-for-byte (ping → pong, workflow_run skip/store paths, push/PR/issues routing, 202 for unknown events).
- Malformed JSON keeps returning the existing 400
bad json. - New worker tests pin the null-body case for at least
workflow_runand one fleet-routed event (push), plus one non-object scalar/array body.
Activity
developing-today commentedon Nov 7, 2026
CODE-2194
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
nullbody (and any non-object JSON body) with a deliberate 400 instead of throwing TypeError out of fetch at the payload.repository deref, before its own try/catch envelope.~/git/fleet/probe-ghci-snapshot(laptop); sibling pattern issue atlas-search(worker): a JSON null body crashes POST /v1/search — body.query dereferences null outside the parse guard, escaping the 400 bad_request envelope #6879 (atlas-search worker null body — different worker/file); same-worker issue github-ci(worker): HMAC gate fails open when GITHUB_WEBHOOK_SECRET is unset — unsigned POSTs are processed and written to Turso #6936 (HMAC gate) and issue github-ci(worker): advanceSnapshot treats an unknown (NULL) default_branch as every branch — a side-branch push overwrites agent_repo_snapshots.head_sha #6945 (advanceSnapshot), both different defectsdeveloping-today commentedon Nov 8, 2026
🤖 Agent note · handed off
opencode16 remaining items
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (fixed_merged)
Implemented direct (lane assignment returned
direct; earlier opencode handoffs produced no PR). PR #8696: after JSON.parse, the github-ci worker now rejects any non-object payload (null/array/string/number/boolean) with a deliberate 400 bad payload for every event type, before any dereference; object-body routing and the bad-json 400 are unchanged. Four new signed-body tests (null × workflow_run/push, array, scalar). Verification on the laptop against the PR head: vitest 33 passed (4 files), tsc --noEmit clean.Merge pull request #8696 from developing-today/queue/11337-6946-ghci-…