1
0
Fork 0
forked from forgejo/forgejo

Check ctx.Written() for GetActionIssue (#25698) (#25711)

Backport #25698 by @wolfogre

Fix #25697.

Just avoid panic, maybe there's another bug to trigger this case.

Co-authored-by: Jason Song <i@wolfogre.com>
This commit is contained in:
Giteabot 2023-07-06 15:04:26 -04:00 committed by GitHub
parent 68e0c802f7
commit 03cacf971e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 11 deletions

View file

@ -1958,7 +1958,7 @@ func GetActionIssue(ctx *context.Context) *issues_model.Issue {
return nil
}
if err = issue.LoadAttributes(ctx); err != nil {
ctx.ServerError("LoadAttributes", nil)
ctx.ServerError("LoadAttributes", err)
return nil
}
return issue
@ -3258,6 +3258,9 @@ func filterXRefComments(ctx *context.Context, issue *issues_model.Issue) error {
// GetIssueAttachments returns attachments for the issue
func GetIssueAttachments(ctx *context.Context) {
issue := GetActionIssue(ctx)
if ctx.Written() {
return
}
attachments := make([]*api.Attachment, len(issue.Attachments))
for i := 0; i < len(issue.Attachments); i++ {
attachments[i] = convert.ToAttachment(issue.Attachments[i])