From e8445d4ff637546f2eb4203a386a318d701af476 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 17 Jun 2022 22:47:15 +0100 Subject: [PATCH] Stop spurious APIFormat stopwatches logs (#20008) If there are dangling stopwatches with missing issues there will be repeated logging of Unable to APIFormat stopwatches. These are unhelpful and instead we should only log if the error is not an issue not exist error. And we should also prevent an error on missing issue in GetActiveStopwatch too Signed-off-by: Andrew Thornton --- modules/eventsource/manager_run.go | 4 +++- routers/web/repo/issue_stopwatch.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/eventsource/manager_run.go b/modules/eventsource/manager_run.go index 6055cf7232c63..06d48454fdee4 100644 --- a/modules/eventsource/manager_run.go +++ b/modules/eventsource/manager_run.go @@ -94,7 +94,9 @@ loop: for _, userStopwatches := range usersStopwatches { apiSWs, err := convert.ToStopWatches(userStopwatches.StopWatches) if err != nil { - log.Error("Unable to APIFormat stopwatches: %v", err) + if !issues_model.IsErrIssueNotExist(err) { + log.Error("Unable to APIFormat stopwatches: %v", err) + } continue } dataBs, err := json.Marshal(apiSWs) diff --git a/routers/web/repo/issue_stopwatch.go b/routers/web/repo/issue_stopwatch.go index 68f89b258dc47..97d4441a27094 100644 --- a/routers/web/repo/issue_stopwatch.go +++ b/routers/web/repo/issue_stopwatch.go @@ -99,7 +99,9 @@ func GetActiveStopwatch(ctx *context.Context) { issue, err := issues_model.GetIssueByID(ctx, sw.IssueID) if err != nil || issue == nil { - ctx.ServerError("GetIssueByID", err) + if !issues_model.IsErrIssueNotExist(err) { + ctx.ServerError("GetIssueByID", err) + } return } if err = issue.LoadRepo(ctx); err != nil {