Skip to content
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

Store API does not surface "key not found" errors #264

Open
pierluca opened this issue Aug 14, 2023 · 0 comments
Open

Store API does not surface "key not found" errors #264

pierluca opened this issue Aug 14, 2023 · 0 comments
Labels
enhancement New feature or request mod/store Concern the store module

Comments

@pierluca
Copy link
Contributor

pierluca commented Aug 14, 2023

The core/store API indicates that nil should be returned when the key does not exist in the key/value store.
This is a behaviour inherited from BBolt, but it's not the most natural implementation. BBolt makes this choice assuming that errors never happen, except for a "key not found", but this assumption may not hold for other stores.
As a consequence, there are two error signals: the returned error and the value returned. This does not allow store users (smart contracts, ...) to cleanly manage the cases where a key does not exist. It would be much preferable (and more explicit) to return a sentinel error to indicate that the key was not found.
This implies updating:

@pierluca pierluca added enhancement New feature or request mod/store Concern the store module labels Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mod/store Concern the store module
Projects
None yet
Development

No branches or pull requests

1 participant