Fix nil pointer dereference when accessing AccountEvent event header account #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #83
This is a tricky issue. The bug is caused by a naming conflicts in the JSON deserialization of an account even payload.
An
AccountEvent
is defined as:This is an example of struct composition in Go. The EventHeader is defined as:
The combined AccountEvent struct is:
When go tries to parse the payload, the two
json:"account"
definitions conflicts each other. The issue arises from the fact the AccountEven is a flatten representation of an Even payload that is actually a nested structure.In Go parsing nested structures is tricky. We took the path to represents events as individual types.
This PR prefixes the event header fields with Event (so Actor becomes EventActor). The event header is parsed independently, and later assigned.