]> source.dussan.org Git - gitea.git/commitdiff
Warn instead of reporting an error when a webhook cannot be found (#26039)
authorpuni9869 <80308335+puni9869@users.noreply.github.com>
Fri, 28 Jul 2023 17:46:48 +0000 (23:16 +0530)
committerGitHub <noreply@github.com>
Fri, 28 Jul 2023 17:46:48 +0000 (17:46 +0000)
Attemp fix: #25744
Fixing the log level when we delete any repo then we get error hook not
found by id. That should be warn level to reduce the noise in the logs.

---------

Co-authored-by: delvh <dev.lh@web.de>
services/webhook/webhook.go

index 3cd9deafd82f767fa1fd064154fe73406e0c7b60..9d5dab85f7977c114eeed8e6acc5fd9ecb2cffb6 100644 (file)
@@ -5,6 +5,7 @@ package webhook
 
 import (
        "context"
+       "errors"
        "fmt"
        "strings"
 
@@ -111,7 +112,11 @@ func handler(items ...int64) []int64 {
        for _, taskID := range items {
                task, err := webhook_model.GetHookTaskByID(ctx, taskID)
                if err != nil {
-                       log.Error("GetHookTaskByID[%d] failed: %v", taskID, err)
+                       if errors.Is(err, util.ErrNotExist) {
+                               log.Warn("GetHookTaskByID[%d] warn: %v", taskID, err)
+                       } else {
+                               log.Error("GetHookTaskByID[%d] failed: %v", taskID, err)
+                       }
                        continue
                }