From b8e67de96549adfc89c54fc7791b81557dfd519e Mon Sep 17 00:00:00 2001 From: Sergei Parshev <8136445+sparshev@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:03:58 -0700 Subject: [PATCH 1/3] Fixed headers for EventType & DeliveryID Apparently github webhook headers are actually have uppercase "H" in "GitHub", instead "Github": ``` map[Accept:*/* Content-Type:application/json User-Agent:GitHub-Hookshot/ef91aa7 X-GitHub-Delivery:****** X-GitHub-Event:workflow_job X-GitHub-Hook-ID:****** X-GitHub-Hook-Installation-Target-ID:****** X-GitHub-Hook-Installation-Target-Type:repository X-Hub-Signature:sha1=****** X-Hub-Signature-256:sha256=******] ``` --- github/messages.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/messages.go b/github/messages.go index 2b5cce7504a..4309596ed7c 100644 --- a/github/messages.go +++ b/github/messages.go @@ -38,9 +38,9 @@ const ( // SHA256SignatureHeader is the GitHub header key used to pass the HMAC-SHA256 hexdigest. SHA256SignatureHeader = "X-Hub-Signature-256" // EventTypeHeader is the GitHub header key used to pass the event type. - EventTypeHeader = "X-Github-Event" + EventTypeHeader = "X-GitHub-Event" // DeliveryIDHeader is the GitHub header key used to pass the unique ID for the webhook event. - DeliveryIDHeader = "X-Github-Delivery" + DeliveryIDHeader = "X-GitHub-Delivery" ) var ( From 9471298d23e30637b791f2c7e12d859f607ee9f4 Mon Sep 17 00:00:00 2001 From: Sergei Parshev <8136445+sparshev@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:06:54 -0700 Subject: [PATCH 2/3] Fixed test for header --- github/messages_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/messages_test.go b/github/messages_test.go index a2b9feac92b..e6508310f17 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -607,7 +607,7 @@ func TestDeliveryID(t *testing.T) { if err != nil { t.Fatalf("DeliveryID: %v", err) } - req.Header.Set("X-Github-Delivery", id) + req.Header.Set("X-GitHub-Delivery", id) got := DeliveryID(req) if got != id { From 48e6ef72a6c6d8cbff09b8054f3110abae12d62f Mon Sep 17 00:00:00 2001 From: Sergei Parshev <8136445+sparshev@users.noreply.github.com> Date: Thu, 17 Apr 2025 21:07:48 -0700 Subject: [PATCH 3/3] Fixed error message as well --- github/messages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/messages.go b/github/messages.go index 4309596ed7c..4a30d69fc66 100644 --- a/github/messages.go +++ b/github/messages.go @@ -321,7 +321,7 @@ func DeliveryID(r *http.Request) string { func ParseWebHook(messageType string, payload []byte) (interface{}, error) { eventType, ok := messageToTypeName[messageType] if !ok { - return nil, fmt.Errorf("unknown X-Github-Event in message: %v", messageType) + return nil, fmt.Errorf("unknown X-GitHub-Event in message: %v", messageType) } event := Event{