From 3de98407374f8c30a64af9a76899b2c7e9012686 Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Wed, 18 Dec 2024 15:07:46 +0800 Subject: [PATCH] fix(tapd): fix overflow when converting lead time minutes (#8244) --- backend/plugins/tapd/tasks/bug_converter.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/plugins/tapd/tasks/bug_converter.go b/backend/plugins/tapd/tasks/bug_converter.go index 635b153dcac..1ae6eaefeab 100644 --- a/backend/plugins/tapd/tasks/bug_converter.go +++ b/backend/plugins/tapd/tasks/bug_converter.go @@ -18,6 +18,7 @@ limitations under the License. package tasks import ( + "math" "reflect" "strconv" "time" @@ -88,8 +89,12 @@ func ConvertBug(taskCtx plugin.SubTaskContext) errors.Error { results = append(results, issueAssignee) } if domainL.ResolutionDate != nil && domainL.CreatedDate != nil { - temp := uint(domainL.ResolutionDate.Sub(*domainL.CreatedDate).Minutes()) - domainL.LeadTimeMinutes = &temp + durationInMinutes := domainL.ResolutionDate.Sub(*domainL.CreatedDate).Minutes() + // we have found some issues' ResolutionDate is earlier than CreatedDate in tapd. + if durationInMinutes > 0 && durationInMinutes < math.MaxUint { + temp := uint(durationInMinutes) + domainL.LeadTimeMinutes = &temp + } } boardIssue := &ticket.BoardIssue{ BoardId: getWorkspaceIdGen().Generate(toolL.ConnectionId, toolL.WorkspaceId),