refactor(ctrl): migrate GitHub webhook onto pkg/webhook receiver#6427
refactor(ctrl): migrate GitHub webhook onto pkg/webhook receiver#6427Flo4604 wants to merge 1 commit into
Conversation
c3a9bea to
401e210
Compare
dfe20e6 to
be5f825
Compare
401e210 to
0e7aa44
Compare
be5f825 to
7dccd9a
Compare
4086a2d to
81e019b
Compare
8f4c46e to
c9762cd
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — since the prior pullfrog review at 2a02720, the source went through several byte-identical rebases (f1022af → 3f30dde → 8f4c46e); the only real deltas at the current head c9762cd are a webhook-registration argument-order flip and a test header addition.
Onregistration flipped to events-first —NewGitHubWebhooknow callsOn([]string{"push"}, webhook.Typed(s.handlePush))(and likewise forpull_requestand the lifecycle events) instead of the handler-first form. This matches the framework's actual signatureOn(eventTypes []string, fn HandlerFunc)and directly adopts the suggestion chronark raised ongithub_webhook.go:33.- Idempotency-key path now exercised in tests —
sendWebhooksetsX-GitHub-Delivery: delivery-test, so the integration tests now drive thedeliveryID := event.IDbranch that attachesWithIdempotencyKeyto the RestateSend.
I confirmed run.go and BUILD.bazel are byte-for-byte identical to the last reviewed source, so the only behavior-relevant change is the registration flip, which I verified compiles correctly against pkg/webhook/receiver.go's On(eventTypes []string, fn HandlerFunc). The new delivery header strengthens coverage of the idempotency-key path; it is set but not asserted, which is fine — DeliveryId propagation isn't the subject of these tests.
The two documented behavior changes from the original review are unchanged, and chronark's open thread on argument order is now satisfied by the code (left for chronark to resolve). The separate "why not return a proper 400 on malformed payloads" question remains an author decision and is untouched by these commits.
Claude Opus | 𝕏
81e019b to
1fa2934
Compare
c9762cd to
aed0efd
Compare
| On([]string{"push"}, webhook.Typed(s.handlePush)). | ||
| On([]string{"pull_request"}, webhook.Typed(s.handlePullRequest)). | ||
| // Branch lifecycle events carry no code to deploy; the first push of a | ||
| // new branch arrives as its own push event (created: true), which is | ||
| // what triggers preview deployments. | ||
| On([]string{"create", "delete", "installation"}, ignoreEvent). | ||
| // GitHub Apps receive every subscribed event type; anything without a | ||
| // handler is deliberately not deployment-relevant. |
1fa2934 to
bc0dadd
Compare
aed0efd to
c867d13
Compare
bc0dadd to
370526b
Compare
c867d13 to
a04a0ba
Compare
370526b to
8ade5dd
Compare
a04a0ba to
1e4a713
Compare
8ade5dd to
7c6c4a2
Compare
1e4a713 to
97856f9
Compare

Migrates ctrl-api's GitHub webhook from a hand-rolled http.Handler onto the
pkg/webhook receiver, making it the second consumer after Stripe.
routing, metrics, retry semantics) move to pkg/webhook +
verifiers/github; the handler file shrinks to business logic only.
parsing, same Restate ingress Send with the delivery id as idempotency
key (now sourced from event.ID via X-GitHub-Delivery).
uninteresting actions) now return webhook.ErrIgnore with a reason, so
they 200 and surface as outcome=ignored in
unkey_webhook_events_total{provider="github"} instead of being invisible.
else falls through to a Default handler that ignores with a logged
reason, replacing the old "Unhandled event type" log line.
Behavior changes, both edge cases: malformed payloads on verified requests
now return 500 instead of 400 (GitHub does not auto-retry either way), and
unknown event types are logged through the receiver's ignored path rather
than a bespoke log line.
Verified: bazel test //svc/ctrl/api/... //pkg/webhook/... (the existing
webhook integration tests pass unchanged: push dispatch, fork PRs, deleted
branches, created branches, invalid signature 401).