Skip to content

Commit 805e7fb

Browse files
jackzampolincwgoes
authored andcommitted
Merge PR #3806: Fix nil returned in Unmarshal functions
* Fix nils returned in unmarshal functions * Address comments
1 parent dcc3357 commit 805e7fb

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

PENDING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ CLI flag.
107107
### Gaia
108108

109109
* [\#3777](https://github.com/cosmso/cosmos-sdk/pull/3777) `gaiad export` no longer panics when the database is empty
110+
* [\#3806](https://github.com/cosmos/cosmos-sdk/pull/3806) Properly return errors from a couple of struct Unmarshal functions
110111

111112
### SDK
112113

types/address.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (va *ValAddress) UnmarshalJSON(data []byte) error {
279279

280280
err := json.Unmarshal(data, &s)
281281
if err != nil {
282-
return nil
282+
return err
283283
}
284284

285285
va2, err := ValAddressFromBech32(s)
@@ -415,7 +415,7 @@ func (ca *ConsAddress) UnmarshalJSON(data []byte) error {
415415

416416
err := json.Unmarshal(data, &s)
417417
if err != nil {
418-
return nil
418+
return err
419419
}
420420

421421
ca2, err := ConsAddressFromBech32(s)

x/gov/depositsvotes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (vo *VoteOption) UnmarshalJSON(data []byte) error {
135135
var s string
136136
err := json.Unmarshal(data, &s)
137137
if err != nil {
138-
return nil
138+
return err
139139
}
140140

141141
bz2, err := VoteOptionFromString(s)

x/gov/proposals.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (pt *ProposalKind) UnmarshalJSON(data []byte) error {
206206
var s string
207207
err := json.Unmarshal(data, &s)
208208
if err != nil {
209-
return nil
209+
return err
210210
}
211211

212212
bz2, err := ProposalTypeFromString(s)
@@ -307,7 +307,7 @@ func (status *ProposalStatus) UnmarshalJSON(data []byte) error {
307307
var s string
308308
err := json.Unmarshal(data, &s)
309309
if err != nil {
310-
return nil
310+
return err
311311
}
312312

313313
bz2, err := ProposalStatusFromString(s)

0 commit comments

Comments
 (0)