Skip to content

Commit

Permalink
server: checkCancelPrivelege should return proper gRPC error status
Browse files Browse the repository at this point in the history
Resolves #77676

The callers of `checkCancelPrivilege` expects returned errors
to be proper gRPC error statuses. Previously, there was one
plain error being returned that was not properly wrapped and
logged. This commit converts that error into a serverError.

Release note: None
  • Loading branch information
xinhaoz committed Mar 21, 2022
1 parent b3525c9 commit 4289946
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/server/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ func findSessionByQueryID(queryID string) sessionFinder {
}
}

// checkCancelPrivilege returns nil if the user has the necessary cancel action
// privileges for a session. This function returns a proper gRPC error status.
func (b *baseStatusServer) checkCancelPrivilege(
ctx context.Context, username security.SQLUsername, findSession sessionFinder,
) error {
Expand All @@ -264,7 +266,7 @@ func (b *baseStatusServer) checkCancelPrivilege(
{
sessionUser, isAdmin, err := b.privilegeChecker.getUserAndRole(ctx)
if err != nil {
return err
return serverError(ctx, err)
}
if username.Undefined() || username == sessionUser {
reqUser = sessionUser
Expand Down

0 comments on commit 4289946

Please sign in to comment.