Skip to content

Commit

Permalink
fix(kwallet): empty wallet key query
Browse files Browse the repository at this point in the history
When querying a key in an empty kwallet wallet, we receive the following error:
```
Error: unexpected end of JSON input
```
This is because the `k.wallet.ReadEntry` returns empty bytes and no error. Hence we should handle a case for empty bytes.

Reference: cosmos/cosmos-sdk#9562
  • Loading branch information
robert-zaremba authored Jun 22, 2021
1 parent d9b6b92 commit ef00f8a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (k *kwalletKeyring) Get(key string) (Item, error) {
if err != nil {
return Item{}, err
}
if len(data) == 0 {
return Item{}, ErrKeyNotFound
}


item := Item{}
err = json.Unmarshal(data, &item)
Expand Down

0 comments on commit ef00f8a

Please sign in to comment.