From 9b277158758c0bf2cab014ca7b655681eb785375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 19 Jan 2023 17:54:06 +0100 Subject: [PATCH] Fix assignment to `cm.AssigneeID` when importing comments This is a fix for https://github.com/go-gitea/gitea/pull/22510 The code assumed that the `AssigneeID` from the comment YAML was an `int64`, but it is actually an `int`, causing a panic. It also had no check on whether the type cast was actually valid, so badly formatted YAML could also cause a panic. Both these issues have been fixed. --- services/migrations/gitea_uploader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index f43c7378b878d..20370d99f9824 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -468,7 +468,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { switch cm.Type { case issues_model.CommentTypeAssignees: - cm.AssigneeID = comment.Meta["AssigneeID"].(int64) + if assigneeID, ok := comment.Meta["AssigneeID"].(int); ok { + cm.AssigneeID = int64(assigneeID) + } if comment.Meta["RemovedAssigneeID"] != nil { cm.RemovedAssignee = true }