sassoftware / event-provenance-registry

The Event Provenance Registry (EPR) is a service that manages and stores events and tracks event-receivers and event-receiver-groups.
Apache License 2.0
5 stars 4 forks source link

fix: find by id should return err if not found #85

Closed caproven closed 6 months ago

caproven commented 7 months ago

Latest merge had issue where, through rest, querying for resources by id would return an empty data array and no errors.

This occurs because db searching was switched from First() to Where(<filter>).Find(). The latter does not return gorm.ErrRecordNotFound, so our code needs a check for empty results.

This PR fixes that issue, along with some adjacent error fixes. Primarily, errors bubbled up to the rest pkg from storage should not be wrapped in eprErrors.MissingObjectError. Not all errors from the db indicate missing objects (such as connection issues), so the storage layer should interpret errors and surface what it can.