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

gateway: improve error codes when removing space members #4652

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: better error codes when removing a space member

The gateway returns more specific error codes when removing a space member fails.

https://github.com/cs3org/reva/pull/4652
https://github.com/owncloud/ocis/issues/8819
11 changes: 7 additions & 4 deletions internal/grpc/services/gateway/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ func (s *svc) updateSpaceShare(ctx context.Context, req *collaboration.UpdateSha
return nil, errors.Wrap(err, "gateway: error getting grant to remove from storage")
}
if !isSpaceManagerRemaining(listGrantRes.GetGrants(), grant.GetGrantee()) {
return nil, errors.New("gateway: can't remove the last manager")
return &collaboration.UpdateShareResponse{
Status: status.NewPermissionDenied(ctx, errtypes.PermissionDenied(""), "can't remove the last manager"),
}, nil
}
}
st, err = s.updateGrant(ctx, req.GetShare().GetResourceId(), grant, opaque)
Expand Down Expand Up @@ -477,8 +479,7 @@ func (s *svc) removeGrant(ctx context.Context, id *provider.ResourceId, g *provi
return nil, errors.Wrap(err, "gateway: error calling RemoveGrant")
}
if grantRes.Status.Code != rpc.Code_CODE_OK {
return status.NewInternal(ctx,
"error removing storage grant"), nil
return grantRes.GetStatus(), nil
}

return status.NewOK(ctx), nil
Expand Down Expand Up @@ -723,7 +724,9 @@ func (s *svc) removeSpaceShare(ctx context.Context, ref *provider.ResourceId, gr
}

if len(listGrantRes.Grants) == 1 || !isSpaceManagerRemaining(listGrantRes.Grants, grantee) {
return nil, errors.New("gateway: can't remove the last manager")
return &collaboration.RemoveShareResponse{
Status: status.NewPermissionDenied(ctx, errtypes.PermissionDenied(""), "can't remove the last manager"),
}, nil
}

// TODO: change CS3 APIs
Expand Down
Loading