0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-21 22:18:23 +01:00

Avoid nil issue when GetIssueByID fails

Use a temporary variable so issue is only overwritten on success,
preventing a nil dereference in notify_service.CreateIssueComment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-02-18 05:26:40 +01:00
parent 648c1714fe
commit 82b3f5ffd5
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443

View File

@ -82,8 +82,10 @@ func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_m
}
// reload issue to ensure it has the latest data, especially the number of comments
if issue, err = issues_model.GetIssueByID(ctx, issue.ID); err != nil {
if reloadedIssue, err := issues_model.GetIssueByID(ctx, issue.ID); err != nil {
log.Error("GetIssueByID: %v", err)
} else {
issue = reloadedIssue
}
notify_service.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)