From 805e7fbfc247e07f396f8f06b7b4d243f86a986e Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Wed, 6 Mar 2019 03:38:18 -0800 Subject: [PATCH] Merge PR #3806: Fix nil returned in Unmarshal functions * Fix nils returned in unmarshal functions * Address comments --- PENDING.md | 1 + types/address.go | 4 ++-- x/gov/depositsvotes.go | 2 +- x/gov/proposals.go | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/PENDING.md b/PENDING.md index a92f01e1d..a8a3efc45 100644 --- a/PENDING.md +++ b/PENDING.md @@ -107,6 +107,7 @@ CLI flag. ### Gaia * [\#3777](https://github.com/cosmso/cosmos-sdk/pull/3777) `gaiad export` no longer panics when the database is empty +* [\#3806](https://github.com/cosmos/cosmos-sdk/pull/3806) Properly return errors from a couple of struct Unmarshal functions ### SDK diff --git a/types/address.go b/types/address.go index 01d3a412f..05a18ecab 100644 --- a/types/address.go +++ b/types/address.go @@ -279,7 +279,7 @@ func (va *ValAddress) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &s) if err != nil { - return nil + return err } va2, err := ValAddressFromBech32(s) @@ -415,7 +415,7 @@ func (ca *ConsAddress) UnmarshalJSON(data []byte) error { err := json.Unmarshal(data, &s) if err != nil { - return nil + return err } ca2, err := ConsAddressFromBech32(s) diff --git a/x/gov/depositsvotes.go b/x/gov/depositsvotes.go index 059d0a6bc..9a97401f7 100644 --- a/x/gov/depositsvotes.go +++ b/x/gov/depositsvotes.go @@ -135,7 +135,7 @@ func (vo *VoteOption) UnmarshalJSON(data []byte) error { var s string err := json.Unmarshal(data, &s) if err != nil { - return nil + return err } bz2, err := VoteOptionFromString(s) diff --git a/x/gov/proposals.go b/x/gov/proposals.go index 49095fb1a..94ffc151b 100644 --- a/x/gov/proposals.go +++ b/x/gov/proposals.go @@ -206,7 +206,7 @@ func (pt *ProposalKind) UnmarshalJSON(data []byte) error { var s string err := json.Unmarshal(data, &s) if err != nil { - return nil + return err } bz2, err := ProposalTypeFromString(s) @@ -307,7 +307,7 @@ func (status *ProposalStatus) UnmarshalJSON(data []byte) error { var s string err := json.Unmarshal(data, &s) if err != nil { - return nil + return err } bz2, err := ProposalStatusFromString(s)