Merge message template and close issue references cause 500 error #10239

Closed
opened 2025-11-02 09:01:53 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @brechtvl on GitHub (Feb 8, 2023).

Description

In a new repository

  • Create .gitea/default_merge_message/SQUASH_TEMPLATE.md with contents for example:
${PullRequestTitle}
  • Create an issue
  • Create a pull request with title Fix #1
  • 500 error when going to the pull request page

It's crashing at services/pull/merge.go:101 while constructing $ClosingIssues for the template.

Can be seen here:
https://try.gitea.io/brechtvl/test/pulls/2

Gitea Version

5ae07d4 (main)

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Both self built and try.gitea.io.

Database

None

Originally created by @brechtvl on GitHub (Feb 8, 2023). ### Description In a new repository * Create `.gitea/default_merge_message/SQUASH_TEMPLATE.md` with contents for example: ``` ${PullRequestTitle} ``` * Create an issue * Create a pull request with title `Fix #1` * 500 error when going to the pull request page It's crashing at `services/pull/merge.go:101` while constructing `$ClosingIssues` for the template. Can be seen here: https://try.gitea.io/brechtvl/test/pulls/2 ### Gitea Version 5ae07d4 (main) ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Both self built and try.gitea.io. ### Database None
GiteaMirror added the type/bug label 2025-11-02 09:01:53 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Feb 8, 2023):

The fix seems to be adding a call to ref.LoadIssue(ctx) before closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index))

if err = ref.LoadIssue(ctx); err != nil { return .... err }
closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index))
@wxiaoguang commented on GitHub (Feb 8, 2023): The fix seems to be adding a call to `ref.LoadIssue(ctx)` before `closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index))` ``` if err = ref.LoadIssue(ctx); err != nil { return .... err } closeIssueIndexes = append(closeIssueIndexes, fmt.Sprintf("%s %s%d", closeWord, issueReference, ref.Issue.Index)) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10239