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

Fix internal sever error when visiting a PR that bound to the deleted team #24127

Merged
merged 7 commits into from
Apr 19, 2023

Conversation

sillyguodong
Copy link
Contributor

@sillyguodong sillyguodong commented Apr 14, 2023

Close: #23738

The actual cause of 500 Internal Server Error in the issue is not what is descirbed in the issue.

The actual cause is that after deleting team, if there is a PR which has requested reivew from the deleted team, the comment could not match with the deleted team by assgin_team_id. So the value of .AssigneeTeam (see below code block) is nil which cause 500 error.

{{if .RemovedAssignee}}
{{$.locale.Tr "repo.issues.review.remove_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}}
{{else}}
{{$.locale.Tr "repo.issues.review.add_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}}
{{end}}

To fix this bug, there are the following problems to be resolved:

  • 1. Stroe the name of the team in content column when inserting comment into DB in case that we cannot get the name of team after it is deleted. But for comments that already exist, just display "Unknown Team" Just display "Ghost Team" in the comment if the assgined team is deleted.
  • 2. Delete the PR&team binding (the row of which review_team_id = ${team_id} in table review) when deleting team.
  • 3.For already exist and undeleted binding rows in in table review, we can delete these rows when executing migrations. they do not affect the function, so won't delete them.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 14, 2023

I think it's better to just show "ghost team" or "deleted team" instead of such complex logic.

For example, if you create a team "MyTeam" , then request review from it, then delete it, then create a new "MyTeam", the new team is not the old team.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 14, 2023
@sillyguodong
Copy link
Contributor Author

the new team is not the old team.

Agree. I'm not going to match the two teams if they have the same name, just want to preserve the original information in the comment as much as possible.

@sillyguodong
Copy link
Contributor Author

Just displaying ”Ghost Team“ in the comment looks more concise, and there will be no misunderstanding.
I will use "Ghost Team" instead of original team name...

Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll accept this change for now.
As a long-term solution we need to do something similar to the ghost user and add a ghost team.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 14, 2023

Codecov Report

Merging #24127 (a4de58c) into main (f521e88) will decrease coverage by 0.02%.
The diff coverage is 41.61%.

❗ Current head a4de58c differs from pull request most recent head b6376b7. Consider uploading reports for the commit b6376b7 to get more accurate results

@@            Coverage Diff             @@
##             main   #24127      +/-   ##
==========================================
- Coverage   47.14%   47.13%   -0.02%     
==========================================
  Files        1149     1161      +12     
  Lines      151446   153767    +2321     
==========================================
+ Hits        71397    72471    +1074     
- Misses      71611    72773    +1162     
- Partials     8438     8523      +85     
Impacted Files Coverage Δ
cmd/dump.go 0.64% <0.00%> (-0.03%) ⬇️
cmd/embedded.go 0.00% <0.00%> (ø)
cmd/mailer.go 0.00% <0.00%> (ø)
cmd/manager.go 0.00% <0.00%> (ø)
cmd/manager_logging.go 0.00% <0.00%> (ø)
cmd/migrate_storage.go 5.76% <0.00%> (-0.12%) ⬇️
cmd/restore_repo.go 0.00% <0.00%> (ø)
cmd/web.go 0.00% <0.00%> (ø)
models/actions/run.go 1.63% <0.00%> (-0.10%) ⬇️
models/actions/runner.go 1.44% <ø> (ø)
... and 61 more

... and 156 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sillyguodong sillyguodong changed the title WIP: Fix internal sever error when visiting a PR that bound to the deleted team Fix internal sever error when visiting a PR that bound to the deleted team Apr 17, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 19, 2023
@silverwind silverwind added this to the 1.20.0 milestone Apr 19, 2023
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 19, 2023
@silverwind silverwind enabled auto-merge (squash) April 19, 2023 22:40
@silverwind silverwind merged commit bfecf3b into go-gitea:main Apr 19, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 19, 2023
@wxiaoguang wxiaoguang deleted the bugfix/issue_23738 branch April 20, 2023 01:45
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 20, 2023
* giteaofficial/main: (26 commits)
  Make HTML template functions support context (go-gitea#24056)
  Fix issue attachment handling (go-gitea#24202)
  Update JS dependencies (go-gitea#24218)
  Remove most path-based golangci exclusions (go-gitea#24214)
  [skip ci] Updated translations via Crowdin
  Fix internal sever error when visiting a PR that bound to the deleted team (go-gitea#24127)
  Add owner team permission check test (go-gitea#24096)
  Fix incorrect CORS default values (go-gitea#24206)
  Add repository counter badge to repository tab (go-gitea#24205)
  Fix template error in pull request with deleted head repo (go-gitea#24192)
  Make wiki title supports dashes and improve wiki name related features (go-gitea#24143)
  Fix Resolve Conversation not working in Conversation view (go-gitea#24191)
  Vertical widths of containers removed (go-gitea#24184)
  Don't list root repository on compare page if pulls not allowed (go-gitea#24183)
  Add unset default project column (go-gitea#23531)
  Allow adding new files to an empty repo (go-gitea#24164)
  Add runner check in repo action page (go-gitea#24124)
  Use same action status svg icons on actions list as on action page (go-gitea#24178)
  [skip ci] Updated translations via Crowdin
  fix calReleaseNumCommitsBehind (go-gitea#24148)
  ...

# Conflicts:
#	templates/repo/wiki/view.tmpl
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Reviewers group on PR breakes SQL Database
6 participants