Skip to content

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

Closed
@TheFox0x7

Description

@TheFox0x7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions