Skip to content

Commit 9b27715

Browse files
committed
Fix assignment to cm.AssigneeID when importing comments
This is a fix for go-gitea#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.
1 parent 9f919cf commit 9b27715

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

services/migrations/gitea_uploader.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
468468

469469
switch cm.Type {
470470
case issues_model.CommentTypeAssignees:
471-
cm.AssigneeID = comment.Meta["AssigneeID"].(int64)
471+
if assigneeID, ok := comment.Meta["AssigneeID"].(int); ok {
472+
cm.AssigneeID = int64(assigneeID)
473+
}
472474
if comment.Meta["RemovedAssigneeID"] != nil {
473475
cm.RemovedAssignee = true
474476
}

0 commit comments

Comments
 (0)