-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix 500 when delete orgnization #633
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
Conversation
Why this will resolve the issue? |
https://github.com/go-gitea/gitea/blob/master/models/user.go#L940-L943 Must be return error or you will get the following error message.
|
Reproduce process in https://try.gitea.io/ :
|
@@ -233,7 +233,8 @@ func DeleteOrganization(org *User) (err error) { | |||
} | |||
|
|||
if err = deleteUser(sess, org); err != nil { | |||
return fmt.Errorf("deleteUser: %v", err) | |||
// Note: don't wrapper error here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's obvious to not wrapping this error, so IMHO you can drop this comment.
But I still don't get how this will resolve the issue :) |
I think we need copy function |
@lunny I will do that. |
@lunny Done. I copy function deleteUser to deleteOrg and remove any no need codes. |
@tboerger You can see the following code: https://github.com/go-gitea/gitea/blob/master/routers/org/setting.go#L128-L134 |
So, maybe you can if IsErrUserOwnRepos(err) {
return err
} else if err != nil {
return fmt.Errorf("deleteUser: %v", err)
} |
Otherwise LGTM |
} | ||
|
||
func deleteOrg(e *xorm.Session, u *User) error { | ||
// Check ownership of repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check u is an org?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return err | ||
} | ||
|
||
return RewriteAllPublicKeys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete an org is no need to RewriteAllPublicKeys() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭 I don't know.
@lunny Already done. |
LGTM |
refactor: Add new deleteOrg func. (go-gitea#633)
Fix #614
Error Message
See: https://github.com/go-gitea/gitea/blob/master/models/user.go#L940-L943
ref commit: ba134bd
cc @lunny