Skip to content

Commit

Permalink
Fix assignment to cm.AssigneeID when importing comments (#22528)
Browse files Browse the repository at this point in the history
This is a fix for #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.
  • Loading branch information
drsybren authored Jan 19, 2023
1 parent 9f919cf commit b383652
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b383652

Please sign in to comment.