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

Ocmd error messages (backport from edge to master) #3419

Closed
wants to merge 13 commits into from
Closed
4 changes: 4 additions & 0 deletions changelog/unreleased/improve-ocmd-error-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enhancement: Improve error logging in ocmd flow

https://github.com/cs3org/reva/issues/3365
https://github.com/cs3org/reva/pull/3369
4 changes: 2 additions & 2 deletions internal/grpc/services/ocminvitemanager/ocminvitemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *service) ForwardInvite(ctx context.Context, req *invitepb.ForwardInvite
err := s.im.ForwardInvite(ctx, req.InviteToken, req.OriginSystemProvider)
if err != nil {
return &invitepb.ForwardInviteResponse{
Status: status.NewInternal(ctx, err, "error forwarding invite"),
Status: status.NewInternal(ctx, err, "error forwarding invite:"+err.Error()),
}, nil
}

Expand Down Expand Up @@ -159,7 +159,7 @@ func (s *service) FindAcceptedUsers(ctx context.Context, req *invitepb.FindAccep
acceptedUsers, err := s.im.FindAcceptedUsers(ctx, req.Filter)
if err != nil {
return &invitepb.FindAcceptedUsersResponse{
Status: status.NewInternal(ctx, err, "error finding remote users"),
Status: status.NewInternal(ctx, err, "error finding remote users: "+err.Error()),
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func (h *invitesHandler) findAcceptedUsers(w http.ResponseWriter, r *http.Reques
indentedResponse, _ := json.MarshalIndent(response, "", " ")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
log.Debug().Msg("findAcceptedUsers json response: " + string(indentedResponse))
if _, err := w.Write(indentedResponse); err != nil {
log.Err(err).Msg("Error writing to ResponseWriter")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/http/services/ocmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ func (h *sendHandler) Handler() http.Handler {
req := &provider.StatRequest{Ref: ref}
res2, err := gatewayClient.Stat(authCtx, req)
if err != nil {
log.Error().Msg("error sending: stat file/folder to share")
log.Error().Msg("gatewayClient.Stat operation failed; is the storage backend reachable?")
w.WriteHeader(http.StatusInternalServerError)
return
}

if res2.Status.Code != rpc.Code_CODE_OK {
log.Error().Msg("error returned: stat file/folder to share")
log.Error().Msgf("sourcePath %s does not exist on the storage backend", sourcePath)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/storage/fs/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"

user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
Expand Down Expand Up @@ -229,7 +230,9 @@ func (nc *StorageDriver) do(ctx context.Context, a Action) (int, []byte, error)
return 0, nil, err
}
log.Info().Msgf("nc.do res %s %s", url, string(body))

if resp.StatusCode != http.StatusOK {
return 0, nil, fmt.Errorf("Unexpected response code from EFSS API: " + strconv.Itoa(resp.StatusCode))
}
return resp.StatusCode, body, nil
}

Expand Down