Skip to content

Commit

Permalink
Expand Validator Input Errors (#8090)
Browse files Browse the repository at this point in the history
The reason of why a validator input was failing was very generic,
this allows the actual implementation to state why it failed by
passing the exception forward.

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
  • Loading branch information
mohamedmansour and rauljordan committed Dec 11, 2020
1 parent 99b3835 commit 2e18df6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions validator/rpc/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *Server) Signup(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespo
// We check the strength of the password to ensure it is high-entropy,
// has the required character count, and contains only unicode characters.
if err := promptutil.ValidatePasswordInput(req.Password); err != nil {
return nil, status.Error(codes.InvalidArgument, "Could not validate RPC password input")
return nil, status.Errorf(codes.InvalidArgument, "Could not validate RPC password input: %v", err)
}
hasDir, err := fileutil.HasDir(walletDir)
if err != nil {
Expand All @@ -68,7 +68,7 @@ func (s *Server) Login(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespon
// We check the strength of the password to ensure it is high-entropy,
// has the required character count, and contains only unicode characters.
if err := promptutil.ValidatePasswordInput(req.Password); err != nil {
return nil, status.Error(codes.InvalidArgument, "Could not validate RPC password input")
return nil, status.Errorf(codes.InvalidArgument, "Could not validate RPC password input: %v", err)
}
hashedPasswordPath := filepath.Join(walletDir, HashedRPCPassword)
if !fileutil.FileExists(hashedPasswordPath) {
Expand Down Expand Up @@ -142,7 +142,7 @@ func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordReque
return nil, status.Error(codes.InvalidArgument, "Password does not match confirmation")
}
if err := promptutil.ValidatePasswordInput(req.Password); err != nil {
return nil, status.Error(codes.InvalidArgument, "Could not validate password input")
return nil, status.Errorf(codes.InvalidArgument, "Could not validate password input: %v", err)
}
// Write the new password hash to disk.
if err := s.SaveHashedPassword(req.Password); err != nil {
Expand Down

0 comments on commit 2e18df6

Please sign in to comment.