From 4c3dcdf815e85bc39001ce621671005c68513c05 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Sat, 29 Jul 2023 22:47:46 +0800 Subject: [PATCH] Warn instead of reporting an error when a webhook cannot be found (#26039) (#26211) Backport #26039 by @puni9869 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: puni9869 <80308335+puni9869@users.noreply.github.com> (cherry picked from commit c5fe09db726e2b97b646446976c0968cb0ddd1d5) --- services/webhook/webhook.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go index 4f77e23efc..f15c853331 100644 --- a/services/webhook/webhook.go +++ b/services/webhook/webhook.go @@ -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 }