Skip to content

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

Merged
merged 1 commit into from
Jan 11, 2017
Merged

fix 500 when delete orgnization #633

merged 1 commit into from
Jan 11, 2017

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Jan 10, 2017

Fix #614

Error Message

[...uters/org/setting.go:133 SettingsDelete()] [E] DeleteOrganization: deleteUser: user still has ownership of repositories [uid: 2]

See: https://github.com/go-gitea/gitea/blob/master/models/user.go#L940-L943

ref commit: ba134bd

cc @lunny

@appleboy appleboy changed the title fix: remove org repository. [WIP] fix: remove org repository. Jan 10, 2017
@appleboy appleboy changed the title [WIP] fix: remove org repository. fix 500 when delete orgnization Jan 10, 2017
@lunny
Copy link
Member

lunny commented Jan 10, 2017

Why this will resolve the issue?

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 10, 2017
@lunny lunny added this to the 1.1.0 milestone Jan 10, 2017
@lunny lunny added the type/bug label Jan 10, 2017
@appleboy
Copy link
Member Author

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.

[...uters/org/setting.go:133 SettingsDelete()] [E] DeleteOrganization: deleteUser: user still has ownership of repositories [uid: 2]

@appleboy
Copy link
Member Author

Reproduce process in https://try.gitea.io/ :

  1. Create organization
  2. Create a report on the organization
  3. Delete organization.

@@ -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.
Copy link
Member

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.

@tboerger
Copy link
Member

But I still don't get how this will resolve the issue :)

@lunny
Copy link
Member

lunny commented Jan 10, 2017

I think we need copy function deleteUser to deleteOrg and remove any no need codes. That's better.

@appleboy
Copy link
Member Author

@lunny I will do that.

@appleboy
Copy link
Member Author

@lunny Done. I copy function deleteUser to deleteOrg and remove any no need codes.

@appleboy
Copy link
Member Author

@lunny
Copy link
Member

lunny commented Jan 10, 2017

So, maybe you can

if IsErrUserOwnRepos(err) {
      return err
} else if err != nil {
      return fmt.Errorf("deleteUser: %v", err) 
}

@lunny
Copy link
Member

lunny commented Jan 10, 2017

Otherwise LGTM

}

func deleteOrg(e *xorm.Session, u *User) error {
// Check ownership of repository.
Copy link
Member

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?

Copy link
Member Author

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()
Copy link
Member

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() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

😭 I don't know.

@appleboy
Copy link
Member Author

@lunny Already done.

@tboerger tboerger 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 Jan 10, 2017
@Bwko
Copy link
Member

Bwko commented Jan 11, 2017

LGTM

@tboerger tboerger 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 Jan 11, 2017
@lunny lunny merged commit cbf2a96 into go-gitea:master Jan 11, 2017
@appleboy appleboy deleted the org branch January 11, 2017 14:42
xgitea added a commit to xgitea/gitea that referenced this pull request Jan 11, 2017
refactor: Add new deleteOrg func. (go-gitea#633)
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
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.

Deleting organisation while user is still in it, causes 500 error
4 participants