1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-10-18 06:33:44 -04:00
gitea/routers/web
Jason Song acd7053e9d
Avoid returning without written ctx when posting PR (#31843)
Fix #31625.

If `pull_service.NewPullRequest` return an error which misses each `if`
check, `CompareAndPullRequestPost` will return immediately, since it
doesn't write the HTTP response, a 200 response with empty body will be
sent to clients.

```go
	if err := pull_service.NewPullRequest(ctx, repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil {
		if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
			ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
		} else if git.IsErrPushRejected(err) {
			// ...
			ctx.JSONError(flashError)
		} else if errors.Is(err, user_model.ErrBlockedUser) {
			// ...
			ctx.JSONError(flashError)
		} else if errors.Is(err, issues_model.ErrMustCollaborator) {
			// ...
			ctx.JSONError(flashError)
		}
		return
	}
```

Not sure what kind of error can cause it to happen, so this PR just
expose it. And we can fix it when users report that creating PRs failed
with error responses.

It's all my guess since I cannot reproduce the problem, but even if it's
not related, the code here needs to be improved.
2024-08-16 17:04:54 +00:00
..
admin Support delete user email in admin panel (#31690) 2024-07-25 18:11:04 +08:00
auth OIDC: case-insensitive comparison for auth scheme Basic (#31706) 2024-07-26 19:51:45 +00:00
devtest Refactor names (#31405) 2024-06-19 06:32:45 +08:00
events
explore Add missing repository type filter parameters to pager (#31832) 2024-08-15 16:34:24 +00:00
feed Use GetDisplayName() instead of DisplayName() to generate rss feeds (#31687) 2024-07-25 17:33:02 +08:00
healthcheck
misc
org Add missing repository type filter parameters to pager (#31832) 2024-08-15 16:34:24 +00:00
repo Avoid returning without written ctx when posting PR (#31843) 2024-08-16 17:04:54 +00:00
shared Refactor names (#31405) 2024-06-19 06:32:45 +08:00
user Add missing repository type filter parameters to pager (#31832) 2024-08-15 16:34:24 +00:00
base.go
githttp.go Refactor names (#31405) 2024-06-19 06:32:45 +08:00
goget.go
home.go
metrics.go
nodeinfo.go
passkey.go
swagger_json.go
web.go Support delete user email in admin panel (#31690) 2024-07-25 18:11:04 +08:00
webfinger.go