-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix bug in function decodeReflectJSONStruct #306
base: master
Are you sure you want to change the base?
Fix bug in function decodeReflectJSONStruct #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
json-decode.go
Outdated
@@ -362,7 +362,7 @@ func (cdc *Codec) decodeReflectJSONSlice(bz []byte, info *TypeInfo, rv reflect.V | |||
} | |||
|
|||
// CONTRACT: rv.CanAddr() is true. | |||
func (cdc *Codec) decodeReflectJSONStruct(bz []byte, info *TypeInfo, rv reflect.Value, fopts FieldOptions) (err error) { | |||
func (cdc *Codec) decodeReflectJSONStruct(bz []byte, info *TypeInfo, rv reflect.Value, _ FieldOptions) (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to remove the last parameter? don't see a reason to keep it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's possible. i didn't remove it because the binary version has it:
Lines 763 to 764 in 59d50ef
func (cdc *Codec) decodeReflectBinaryStruct(bz []byte, info *TypeInfo, rv reflect.Value, | |
_ FieldOptions, bare bool) (n int, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated 👍
Are there plans for this to be merged please? |
I don't think this repo is being maintained. Better to fork and continue from there. |
This PR fixes a bug in the function
decodeReflectJSONStruct
.To decode each field of the struct, this function is calling
decodeReflectJSON
. The issue was instead of using eachfield.FieldOptions
, it was passing its parameterfopts FieldOptions
:go-amino/json-decode.go
Line 416 in 59d50ef
The binary version
decodeReflectBinaryStruct
is already using eachfield.FieldOptions
, so I just apply the same logic to the json version.go-amino/binary-decode.go
Line 867 in 59d50ef
I also add a new
Unsafe
struct tojson_test.go
to unit test the issue. Without the fix, the tests are failing.Here is the link to the failed CI test before the fix: https://app.circleci.com/jobs/github/tendermint/go-amino/670