Skip to content

Commit 0ac3186

Browse files
authored
Dont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160)
Backport #28551 RequestReview get deleted on review. So we don't have to try to load them on comments.
1 parent 732d511 commit 0ac3186

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

models/issues/comment.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
688688
}
689689

690690
func (c *Comment) loadReview(ctx context.Context) (err error) {
691+
if c.ReviewID == 0 {
692+
return nil
693+
}
691694
if c.Review == nil {
692695
if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil {
696+
// review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them.
697+
if c.Type == CommentTypeReviewRequest {
698+
return nil
699+
}
693700
return err
694701
}
695702
}

models/issues/comment_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
430430
for _, comment := range comments {
431431
comment.Review = reviews[comment.ReviewID]
432432
if comment.Review == nil {
433-
if comment.ReviewID > 0 {
433+
// review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them.
434+
if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest {
434435
log.Error("comment with review id [%d] but has no review record", comment.ReviewID)
435436
}
436437
continue

models/issues/review.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
622622
return nil, err
623623
}
624624

625+
// func caller use the created comment to retrieve created review too.
626+
comment.Review = review
627+
625628
return comment, committer.Commit()
626629
}
627630

0 commit comments

Comments
 (0)