-
Notifications
You must be signed in to change notification settings - Fork 111
[storage/journal] improve consistency in journal read/get error handling #1565
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
Conversation
246b5b7
to
cdd6d48
Compare
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.
Pull Request Overview
This PR standardizes error handling in journal read/get operations to provide consistent responses when requesting non-existent items. Instead of returning unpredictable error types or None values, the changes ensure that requests for non-existent items consistently return either Pruned or OutOfRange errors.
- Replace inconsistent error handling with standardized SectionOutOfRange and ItemOutOfRange errors
- Remove panic behavior in fixed journal and replace with proper error handling
- Update documentation to clarify error conditions for journal operations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
storage/src/journal/mod.rs | Adds new error variants SectionOutOfRange and ItemOutOfRange, removes InvalidItem |
storage/src/journal/variable.rs | Changes get() method to return SectionOutOfRange error instead of None for missing sections |
storage/src/journal/fixed.rs | Replaces panic with ItemOutOfRange error and improves bounds checking in read() method |
storage/src/adb/any/variable/sync.rs | Updates test assertions and error handling to use new standardized error types |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cdd6d48
to
66e1ac9
Compare
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.
Left a few comments on handling variable
better, once those are resolved it is probably g2g.
0d993c7
to
eeb065b
Compare
Tested on |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1565 +/- ##
=======================================
Coverage 92.09% 92.09%
=======================================
Files 286 286
Lines 73922 73883 -39
=======================================
- Hits 68077 68044 -33
+ Misses 5845 5839 -6
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Our journals respond rather unpredictably when requesting non-existent items. For example, depending on the specific input values, the variable journal might return either None or one of a variety of error types. The fixed journal might return ItemPruned, or instead simply panic if the requested item is out of range.
This PR makes journal reads of non-existent items consistently return either:
The only exception is an invalid variable journal section offset, which we clarify will result in error, but the exact type is undefined.
In no circumstances will a request for a non-existent item return "None".