-
Notifications
You must be signed in to change notification settings - Fork 224
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 JSON deserialization of abci::ResponseInfo #1131
Fix JSON deserialization of abci::ResponseInfo #1131
Conversation
The fields are annotated with json:"omitempty" in the Go source, so give them default values for Deserialize. The /abci_info endpoint is known to omit the app_version field in some recent revisions of Gaia.
(".tendermint.abci.ResponseInfo.data", DEFAULT), | ||
(".tendermint.abci.ResponseInfo.version", DEFAULT), | ||
( | ||
".tendermint.abci.ResponseInfo.app_version", | ||
QUOTED_WITH_DEFAULT, | ||
), | ||
( | ||
".tendermint.abci.ResponseInfo.last_block_height", | ||
QUOTED_WITH_DEFAULT, | ||
), |
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.
Not sure if it's best to fix it here with compiler tweaks, or maybe move the serde annotations to the AbciInfo
struct, where the serde traits are really used, while currently being delegated to tendermint_proto::abci::ResponseInfo
.
We have to customize serde for every field of the involved struct in either case, so doing it directly in source would be cleaner.
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.
Interesting. You'd think "default" de/serializations have been around long enough that this is already listed in the consts
list, but alas...
Anyway, if this works for now, cool.
The only field of abci::ResponseInfo where it remained missing, to match the json:"omitempty" flag in Go.
Codecov Report
@@ Coverage Diff @@
## master #1131 +/- ##
======================================
Coverage 64.7% 64.7%
======================================
Files 231 231
Lines 15637 15637
======================================
+ Hits 10121 10124 +3
+ Misses 5516 5513 -3
Continue to review full report at Codecov.
|
Backport of #1131 to v0.23.x The fields are annotated with json:"omitempty" in the Go source, so give them default values for Deserialize. The /abci_info endpoint is known to omit some of the fields depending on what the node software supplies.
…1156) * Fix JSON deserialization of abci::ResponseInfo Backport of #1131 to v0.23.x The fields are annotated with json:"omitempty" in the Go source, so give them default values for Deserialize. The /abci_info endpoint is known to omit some of the fields depending on what the node software supplies. * Fix a clippy lint * Correct fmt * Use writeln! instead of write! Co-authored-by: Thane Thomson <connect@thanethomson.com>
Fixes: #1132
The fields of the tendermint-go struct equivalent to
abci::ResponseInfo
are annotated withjson:"omitempty"
, so give them default values forDeserialize
. The/abci_info
endpoint is known to omit theapp_version
field in some recent revisions of Gaia..changelog/