nuts-foundation / nuts-registry

Distributed registry for storing and querying healthcare care providers their vendors and technical endpoints.
GNU General Public License v3.0
0 stars 0 forks source link

Fix nilptr deref when v0 events are received through network #159

Closed reinkrul closed 3 years ago

reinkrul commented 3 years ago

Registry v0 events don't have the issuedAt field. When loading from disk this is solved by taking the timestamp from the filename as event timestamp (issuedAt), but this doesn't work when events are received over Nuts Network. In that case issuedAt stays 0 which causes sorting problems when events are received out-of-order because they're sorted on issuedAt. This in turn can lead to a nil pointer dereference because a previous event (prev field) might not have been processed although it should have, because sorting the events made sure previous events are processed first.

This can be fixed quite easily by using the document timestamp as event issuedAt, because document timestamp is filled using issuedAt on the sending side.

Fixes #163

codecov[bot] commented 3 years ago

Codecov Report

Merging #159 (6b52c14) into master (38b7520) will decrease coverage by 0.34%. The diff coverage is 81.25%.

Impacted Files Coverage Δ
pkg/network/ambassador.go 61.76% <0.00%> (-4.91%) :arrow_down:
pkg/events/events.go 83.18% <100.00%> (+1.11%) :arrow_up:
pkg/events/system.go 82.90% <100.00%> (-4.60%) :arrow_down: