@@ -182,7 +182,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
182182 // GitHub webhooks can fire before the pull_requests array is populated
183183 commitSHA := extractCommitSHA (eventType , payload )
184184 // Extract repo URL as fallback for org-based matching
185- repoURL := extractRepoURL (payload )
185+ repoURL := ""
186+ if repo , ok := payload ["repository" ].(map [string ]any ); ok {
187+ if htmlURL , ok := repo ["html_url" ].(string ); ok {
188+ repoURL = htmlURL
189+ }
190+ }
186191
187192 // If we can't extract repo URL, drop the event
188193 if repoURL == "" {
@@ -299,11 +304,15 @@ func ExtractPRURL(eventType string, payload map[string]any) string {
299304 }
300305 }
301306 // Log when we can't extract PR URL from check event
307+ payloadKeys := make ([]string , 0 , len (payload ))
308+ for k := range payload {
309+ payloadKeys = append (payloadKeys , k )
310+ }
302311 logger .Warn ("no PR URL found in check event" , logger.Fields {
303312 "event_type" : eventType ,
304313 "has_check_run" : payload ["check_run" ] != nil ,
305314 "has_check_suite" : payload ["check_suite" ] != nil ,
306- "payload_keys" : getPayloadKeys ( payload ) ,
315+ "payload_keys" : payloadKeys ,
307316 })
308317 default :
309318 // For other event types, no PR URL can be extracted
@@ -378,15 +387,6 @@ func extractPRFromCheckEvent(checkEvent map[string]any, payload map[string]any,
378387 return constructedURL
379388}
380389
381- // getPayloadKeys returns the keys from a payload map for logging.
382- func getPayloadKeys (payload map [string ]any ) []string {
383- keys := make ([]string , 0 , len (payload ))
384- for k := range payload {
385- keys = append (keys , k )
386- }
387- return keys
388- }
389-
390390// getMapKeys returns the keys from a map for logging.
391391func getMapKeys (m map [string ]any ) []string {
392392 keys := make ([]string , 0 , len (m ))
@@ -417,13 +417,3 @@ func extractCommitSHA(eventType string, payload map[string]any) string {
417417 return ""
418418}
419419
420- // extractRepoURL extracts the repository HTML URL from the payload.
421- // This is used as a fallback when PR URL cannot be extracted (e.g., check event race condition).
422- func extractRepoURL (payload map [string ]any ) string {
423- if repo , ok := payload ["repository" ].(map [string ]any ); ok {
424- if htmlURL , ok := repo ["html_url" ].(string ); ok {
425- return htmlURL
426- }
427- }
428- return ""
429- }
0 commit comments