From a17d431c9c073ae01e7d2cef20dd700f9d3b5ad9 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 17 Jun 2022 21:34:34 +0100 Subject: [PATCH 1/2] Stop spurious APIFormat stopwatches logs 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. Signed-off-by: Andrew Thornton --- modules/eventsource/manager_run.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) From de94921e1d6863a094ac0809fc360a9db382c4ad Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 17 Jun 2022 22:04:28 +0100 Subject: [PATCH 2/2] And prevent error on missing issue in GetActiveStopwatch too Signed-off-by: Andrew Thornton --- routers/web/repo/issue_stopwatch.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 {