0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-18 21:50:01 +01:00
gitea/routers/web/repo
Giteabot 1cf8f69b38
Avoid returning without written ctx when posting PR (#31843) (#31848)
Backport #31843 by @wolfogre

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.

Co-authored-by: Jason Song <i@wolfogre.com>
2024-08-16 13:50:12 -04:00
..
actions Fix possible ui 500 if workflow's job is nil (#31092) (#31098) 2024-05-27 14:13:15 +08:00
setting Show lock owner instead of repo owner on LFS setting page (#31788) (#31817) 2024-08-11 15:17:34 +00:00
activity.go
attachment.go
blame.go Refactor file view & render (#30227) 2024-04-01 21:11:30 +08:00
branch.go
cherry_pick.go
code_frequency.go
commit.go Fix code search input for different views (#30678) 2024-04-26 11:21:04 +00:00
compare.go Refactor sha1 and time-limited code (#31023) (#31030) 2024-05-21 00:58:21 +08:00
contributors.go Fix Activity Page Contributors dropdown (#31264) (#31269) 2024-06-06 08:14:00 +00:00
download.go
editor_test.go
editor.go Add missed return after ctx.ServerError (#31130) (#31133) 2024-05-28 12:47:11 +02:00
find.go Escape paths for find file correctly (#30026) 2024-03-23 13:07:47 +00:00
fork.go Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995) 2024-03-22 13:53:52 +01:00
githttp_test.go
githttp.go Make sure git version&feature are always prepared (#30877) (#30879) 2024-05-07 02:07:33 +00:00
helper_test.go
helper.go
issue_content_history.go Migrate margin and padding helpers to tailwind (#30043) 2024-03-24 17:42:49 +01:00
issue_dependency.go
issue_label_test.go
issue_label.go
issue_lock.go
issue_pin.go
issue_stopwatch.go
issue_test.go
issue_timetrack.go
issue_watch.go
issue.go Fix the display of project type for deleted projects (#31732) (#31734) 2024-07-30 14:05:14 +08:00
main_test.go
middlewares.go
migrate.go
milestone.go Remove AddParamIfExist(AddParam) (#29841) 2024-03-16 12:07:56 +00:00
packages.go Remove AddParamIfExist(AddParam) (#29841) 2024-03-16 12:07:56 +00:00
patch.go
projects_test.go
projects.go Fix various problems around projects board view (#30696) (#30902) 2024-05-08 15:46:21 +00:00
pull_review_test.go Fix template error when comment review doesn't exist (#29888) 2024-03-19 04:19:48 +00:00
pull_review.go Prevent allow/reject reviews on merged/closed PRs (#30686) 2024-04-27 11:55:03 +00:00
pull.go Avoid returning without written ctx when posting PR (#31843) (#31848) 2024-08-16 13:50:12 -04:00
recent_commits.go
release_test.go
release.go Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995) 2024-03-22 13:53:52 +01:00
render.go Fix rendered wiki page link (#31398) (#31407) 2024-06-19 11:23:24 +08:00
repo.go Allow downloading attachments of draft releases (#31369) (#31380) 2024-06-16 20:55:14 +08:00
search_test.go Improve grep search (#30843) (#30850) 2024-05-03 17:59:33 +08:00
search.go Improve grep search (#30843) (#30850) 2024-05-03 17:59:33 +08:00
topic.go
treelist.go
view_test.go
view.go Fix rendered wiki page link (#31398) (#31407) 2024-06-19 11:23:24 +08:00
wiki_test.go Use raw Wiki links for non-renderable Wiki files (#30273) 2024-04-10 17:49:57 +00:00
wiki.go Fix wiki revision pagination (#31760) (#31772) 2024-08-04 10:45:41 +08:00