Skip to content

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Sep 8, 2025

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:

  • [Section|Item]Pruned, if the requested item/section has been pruned, or
  • [Section|Item]OutOfRange, if the requested item/section does not exist.

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".

@roberto-bayardo roberto-bayardo force-pushed the journal-get-error-consistency branch from 246b5b7 to cdd6d48 Compare September 8, 2025 22:15
Copy link
Contributor

@Copilot Copilot AI left a 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.

@roberto-bayardo roberto-bayardo force-pushed the journal-get-error-consistency branch from cdd6d48 to 66e1ac9 Compare September 8, 2025 22:23
danlaine
danlaine previously approved these changes Sep 9, 2025
@roberto-bayardo roberto-bayardo marked this pull request as ready for review September 9, 2025 14:59
@patrick-ogrady patrick-ogrady moved this to In Progress in Tracker Sep 9, 2025
Copy link
Contributor

@patrick-ogrady patrick-ogrady left a 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.

@roberto-bayardo roberto-bayardo force-pushed the journal-get-error-consistency branch from 0d993c7 to eeb065b Compare September 9, 2025 22:24
@patrick-ogrady
Copy link
Contributor

Tested on battleware and works as expected 🫡

@patrick-ogrady patrick-ogrady merged commit cff2c74 into main Sep 9, 2025
37 checks passed
@patrick-ogrady patrick-ogrady deleted the journal-get-error-consistency branch September 9, 2025 23:43
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tracker Sep 9, 2025
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 95.50562% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.09%. Comparing base (c30284f) to head (eeb065b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/adb/any/variable/mod.rs 83.33% 1 Missing ⚠️
storage/src/adb/immutable/mod.rs 75.00% 1 Missing ⚠️
storage/src/journal/fixed.rs 90.90% 1 Missing ⚠️
storage/src/journal/variable.rs 87.50% 1 Missing ⚠️
@@           Coverage Diff           @@
##             main    #1565   +/-   ##
=======================================
  Coverage   92.09%   92.09%           
=======================================
  Files         286      286           
  Lines       73922    73883   -39     
=======================================
- Hits        68077    68044   -33     
+ Misses       5845     5839    -6     
Files with missing lines Coverage Δ
storage/src/adb/any/variable/sync.rs 98.81% <100.00%> (-0.03%) ⬇️
storage/src/adb/keyless.rs 94.45% <100.00%> (-0.07%) ⬇️
storage/src/archive/prunable/storage.rs 98.37% <100.00%> (-0.02%) ⬇️
storage/src/cache/storage.rs 97.24% <100.00%> (-0.02%) ⬇️
storage/src/freezer/storage.rs 92.76% <100.00%> (+0.31%) ⬆️
storage/src/journal/mod.rs 66.66% <ø> (ø)
storage/src/store/mod.rs 95.22% <100.00%> (+0.15%) ⬆️
storage/src/store/operation.rs 82.49% <100.00%> (+0.29%) ⬆️
storage/src/adb/any/variable/mod.rs 96.09% <83.33%> (+0.22%) ⬆️
storage/src/adb/immutable/mod.rs 95.69% <75.00%> (+0.14%) ⬆️
... and 2 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c30284f...eeb065b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants