Repository navigation
Answer the GitHub ping event - #17
Merged
Merged
Conversation
GitHub sends a ping event to the webhook URL when the hook is created or activated. The receiver answered 400: the X-GitHub-Event header enum only accepted the event of the path, and the ping body was validated against the event schema. Accept ping on the pullrequest, push and release paths, validate its body with a new Ping schema (oneOf with the event schema), and answer 200 pong after the signature check. A ping body sent with another event header is rejected with 400.
arnaudveron
marked this pull request as ready for review
October 22, 2026 05:37
cgalibern
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Answer the GitHub
pingevent with 200. GitHub sends it to the webhook URL when a hook is created or activated, and today the receiver answers 400, so the new hook shows a failed delivery.Cause
connexion validates the request before the controller (and
@verify) runs:X-GitHub-Eventheader enum only accepts the event of the path (pull_request,pushorrelease);'action' is a required property).Changes
swagger/github.yaml:pingadded to theX-GitHub-Eventenum of the 3 paths. Each request body is nowoneOf: [<Event>, Ping], with a newPingschema (zenandhook_idrequired).controllers/events.py: apingevent answers200 {"message": "pong", "zen": ..., "hook_id": ...}. A ping body sent with another event header is rejected with 400. Other events take the same path as before. The signature is still checked by@verify.Trade-off: an invalid pull_request/push/release payload still gets a 400, but the message is the generic
oneOfone instead of naming the missing property. The alternative is a Flaskbefore_requesthook that answers ping before the validation. It keeps the detailed messages, but it is outside the OpenAPI spec and duplicates the signature check.Tested
Local image built from this branch,
SECRETset, requests signed in sha1 and sha256:/pullrequest,/release,/pushactionX-GitHub-Event: pull_requestX-Hub-SignatureIndependent of #16 (skip draft pull requests).
Not in this PR, possible follow-ups:
signature.pyonly checks the sha1X-Hub-Signature, and compares with!=instead ofhmac.compare_digest.context/github_release.pyraisesKeyError(500) whenrelease.authoris missing.