Skip to content

Commit

Permalink
Bugfix: Fix CS3 status code when looking up non existing share
Browse files Browse the repository at this point in the history
When trying to lookup a share that does not exist we now return a proper "not found"
error instead of just an "internal error.
  • Loading branch information
rhafer committed Nov 27, 2023
1 parent a16959a commit ff25cbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-getshare-statuscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix CS3 status code when looking up non existing share

When trying to lookup a share that does not exist we now return a proper "not found"
error instead of just an "internal error.

https://github.com/cs3org/reva/pull/4366
10 changes: 9 additions & 1 deletion internal/grpc/services/usershareprovider/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"regexp"

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -209,8 +210,15 @@ func (s *service) RemoveShare(ctx context.Context, req *collaboration.RemoveShar
func (s *service) GetShare(ctx context.Context, req *collaboration.GetShareRequest) (*collaboration.GetShareResponse, error) {
share, err := s.sm.GetShare(ctx, req.Ref)
if err != nil {
var st *rpc.Status
switch err.(type) {
case errtypes.IsNotFound:
st = status.NewNotFound(ctx, err.Error())
default:
st = status.NewInternal(ctx, err.Error())
}
return &collaboration.GetShareResponse{
Status: status.NewInternal(ctx, "error getting share"),
Status: st,
}, nil
}

Expand Down

0 comments on commit ff25cbb

Please sign in to comment.