Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert templates on pull request comparison page don't work #33013

Closed
TheFox0x7 opened this issue Dec 27, 2024 · 0 comments · Fixed by #33025
Closed

Alert templates on pull request comparison page don't work #33013

TheFox0x7 opened this issue Dec 27, 2024 · 0 comments · Fixed by #33025
Labels

Comments

@TheFox0x7
Copy link
Contributor

Description

Reproduction steps:

  1. Create user1 and user2
  2. user1 creates a repository "example"
  3. user2 forks it and makes some change
  4. user1 blocks user2
  5. user2 tries to submit PR

Expected outcome:
User2 gets a message that they are blocked from repository.

Actual:
Template fails and displays server error.


Analysis:

Parameters passed to the template lack Details key which causes the error.

gitea/routers/web/repo/pull.go

Lines 1355 to 1369 in 079a1ff

case errors.Is(err, user_model.ErrBlockedUser):
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.push_rejected"),
"Summary": ctx.Tr("repo.pulls.new.blocked_user"),
})
if err != nil {
ctx.ServerError("CompareAndPullRequest.HTMLString", err)
return
}
ctx.JSONError(flashError)
case errors.Is(err, issues_model.ErrMustCollaborator):
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.push_rejected"),
"Summary": ctx.Tr("repo.pulls.new.must_collaborator"),
})

Adding it with even an empty string resolves the issue.
I haven't tried to do this on demo instance.

Gitea Version

079a1ff

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

Expected:
image

Actual:
image

Git Version

2.47.1

Operating System

Linux

How are you running Gitea?

self-built

Database

SQLite

GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Dec 29, 2024
wxiaoguang pushed a commit that referenced this issue Dec 29, 2024
Backport #33025 by TheFox0x7

Adds test for expected behavior

Closes: #33013

---

Co-authored-by: TheFox0x7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant