Procházet zdrojové kódy

fix(webhooks): log match and no-match outcomes

Makes unmatched POSTs visible at info so operators can debug upstream delivery without guessing from silent 200 OK responses.

Co-authored-by: Cursor <cursoragent@cursor.com>
jamesread před 15 hodinami
rodič
revize
86d9ab4a8b
1 změnil soubory, kde provedl 11 přidání a 2 odebrání
  1. 11 2
      service/internal/webhooks/handler.go

+ 11 - 2
service/internal/webhooks/handler.go

@@ -41,19 +41,28 @@ func (h *WebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Request) {
 
 	matchingActions := h.findMatchingActions(r, payload)
 	if len(matchingActions) == 0 {
+		log.WithFields(webhookRequestFields(r)).Infof("Webhook: no matching actions")
 		h.writeOKResponse(w, "no matching webhook actions")
 		return
 	}
 
 	processed := h.processMatchingActions(matchingActions, r, payload)
-	log.WithFields(log.Fields{
+	log.WithFields(webhookRequestFields(r)).WithFields(log.Fields{
 		"matched":   len(matchingActions),
 		"processed": processed,
-	}).Infof("Webhook processed")
+	}).Infof("Webhook: matched")
 
 	h.writeOKResponse(w, "webhook actions")
 }
 
+func webhookRequestFields(r *http.Request) log.Fields {
+	return log.Fields{
+		"method": r.Method,
+		"path":   r.URL.Path,
+		"query":  r.URL.RawQuery,
+	}
+}
+
 func (h *WebhookHandler) readPayload(r *http.Request) ([]byte, error) {
 	maxSize := int64(1024 * 1024)
 	payload, err := io.ReadAll(io.LimitReader(r.Body, maxSize))