Repository navigation
Description
Problem
The github-backup queue Worker's webhook endpoint (POST /github in infra/github-backup/worker/src/index.js) trusts two things it should guard, and both failures escape the handler as unhandled throws instead of responses. Sibling endpoints in the same file were covered by #6882 (/queue/ack body shape, corrupt KV on GET /queue); the /github handler was not.
File: infra/github-backup/worker/src/index.js (verified on origin/main @ 86afa3b8b6; the file is unchanged since 63f83bef5a).
1. A signed JSON null body crashes the handler (:45-47)
let payload = {};
try { payload = JSON.parse(body); } catch { /* ping has form encoding sometimes */ }
...
const repo = payload.repository && payload.repository.full_name;The try/catch guards only the parse. A body of null parses successfully to null, and payload.repository then throws TypeError: Cannot read properties of null (reading 'repository'). Every other non-object body behaves sanely today ([], "hi", 123, and non-JSON all get 202 no repository in payload), and the ping path returns before the deref — null is the one shape that crashes the receiver for a legitimately signed delivery.
2. An unset/empty GITHUB_WEBHOOK_SECRET crashes every delivery, naming nothing (:38-41)
const expect = await hmacHex(env.GITHUB_WEBHOOK_SECRET, body);hmacHex encodes the secret and calls crypto.subtle.importKey with it. With the secret unset or empty, the key is zero-length and importKey throws DOMException: Zero-length key is not supported — for every POST, signed or not, before the signature comparison. A misconfigured deployment (secret not provisioned, or provisioned empty) therefore takes the webhook receiver down with a bare 500 whose error names neither the endpoint nor the missing configuration, instead of an explicit fail-closed configuration error.
Evidence
Verified this run on the laptop, probe ~/git/fleet/probe-ghb-github (real src/index.js verbatim, md5 931e7df400d74fb6d60d38698205f2c4 matching origin/main, node v24.21.0, stub KV, HMACs computed with node:crypto):
| Case | Result today |
|---|---|
| secret set, correct signature, repo payload | 202 queued, 1 KV write (control OK) |
| secret set, wrong signature / no signature | 401 bad signature, 0 KV writes (control OK) |
secret set, correct signature, body null |
throws TypeError: Cannot read properties of null (reading 'repository') |
secret set, correct signature, body [] / "hi" / 123 / non-JSON |
202 no repository in payload (controls OK) |
secret set, event ping, body null |
200 pong (returns before the deref) |
secret unset or "", any signature (even a correct empty-key HMAC) or none |
throws DOMException: Zero-length key is not supported |
The existing suite (infra/github-backup/worker/test/index.test.mjs, 5 tests) has no /github coverage at all.
Why it matters
- This Worker is the freshness signal for the estate mirror system (github-backup: estate mirror system (laptop mirrors + dedicated App + Worker webhooks + weekly sweep) #3215): webhook events feed the drainer queue. A signed
nulldelivery (a malformed or hand-crafted payload from the GitHub App) currently produces an unhandled 500 instead of the202the handler already returns for every other repository-less shape — noise in delivery logs and a redelivery loop for a payload that can never succeed. - A missing secret is exactly the failure a deploy can ship silently (see the deploy-side history in github-backup(deploy): the version advertised for rollback is the pre-secrets version, and --deploy-version never provisions secrets #3475/github-backup(deploy): normal flow silently falls back to the pre-secrets upload as rollback target when the configured-live re-read is empty (#3510 residual) #6507): today it surfaces only as an opaque per-request exception, indistinguishable from a runtime bug, instead of one clear "secret not configured" response an operator (or an alarm) can act on. The fix must stay fail-closed: no signature is ever accepted without a configured secret.
Acceptance criteria
-
POST /githubwith a correctly signed JSONnullbody returns202 no repository in payload(same as the other non-object shapes); no exception escapes the handler for any parsed JSON value. -
POST /githubwithGITHUB_WEBHOOK_SECRETunset or empty returns an explicit 5xx whose body names the missing configuration, for every request; no exception escapes, no KV write occurs, and no signature (including an empty-key HMAC) is accepted. - Well-formed deliveries are unchanged: correct signature + repository payload →
202 queuedwith the event stored; wrong/missing signature →401;ping→200 pong. - New tests in
infra/github-backup/worker/test/index.test.mjscover: signednullbody, unset secret, empty secret; the existing 5 tests still pass (node --test infra/github-backup/worker/test/index.test.mjs).
Activity
developing-today commentedon Nov 7, 2026
CODE-2197
dezren39 commentedon Nov 7, 2026
🤖 Agent note · state: filed
Merge pull request #6952 from developing-today/creator-b/6951-ghb-git…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · state: done