From b383652e02294796fdab7270e2cdb5a0d7413511 Mon Sep 17 00:00:00 2001 From: Sybren <122987084+drsybren@users.noreply.github.com> Date: Thu, 19 Jan 2023 19:24:40 +0100 Subject: [PATCH] Fix assignment to `cm.AssigneeID` when importing comments (#22528) 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 f43c7378b..20370d99f 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 }