Skip to content

fix(storage):make init_store return Result#448

Merged
MegaRedHand merged 2 commits into
lambdaclass:mainfrom
d4m014:fix/store-init-result
Jun 19, 2026
Merged

fix(storage):make init_store return Result#448
MegaRedHand merged 2 commits into
lambdaclass:mainfrom
d4m014:fix/store-init-result

Conversation

@d4m014

@d4m014 d4m014 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🗒️ Description / Motivation

First step of migrating Store functions to return Result instead of panicking.
Changes init_store to return Result<Self, Error>, wrapping the return value in Ok(...). All existing .expect() calls inside the function body are left as-is for now, error propagation will come in follow-up PRs.

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt — clean
  • Ran make lint (clippy with -D warnings) — clean
  • Ran cargo test --workspace --release — all passing

@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This is the first step of migrating Store methods to return Result instead of panicking. init_store now returns Result<Self, Error>, with the Self construction wrapped in Ok(...); callers temporarily unwrap with .expect() until full propagation lands in follow-up PRs.

  • init_store signature changed from -> Self to -> Result<Self, Error>, with the constructed value wrapped in Ok(Self { ... }).
  • from_anchor_state and get_forkchoice_store updated to call .expect() on the Result, preserving existing panic behavior while unlocking future error propagation.

Confidence Score: 4/5

Safe to merge — the change is a minimal signature update with no behavioral difference today.

The only change is wrapping the return value in Ok(...) and adding .expect() at both call sites, preserving existing panic behavior. The sole finding is a stray leading space in one expect message.

No files require special attention.

Important Files Changed

Filename Overview
crates/storage/src/store.rs Changes init_store signature from -> Self to -> Result<Self, Error> and wraps the return in Ok(...). Both callers (from_anchor_state, get_forkchoice_store) now unwrap via .expect(). Minor: a stray leading space in the get_forkchoice_store expect message.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
crates/storage/src/store.rs:536
There is a leading space in the panic message — `" store initialization..."` — that differs from the message used in `from_anchor_state`.

```suggestion
                .expect("store initialization should succeed in get_forkchoice_store"),
```

Reviews (1): Last reviewed commit: "make init_store return Result" | Re-trigger Greptile

Comment thread crates/storage/src/store.rs Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@MegaRedHand MegaRedHand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a comment regarding future direction

mut anchor_state: State,
anchor_body: Option<BlockBody>,
) -> Self {
) -> Result<Self, Error> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads-up, but we probably need some other crate::error::Error enum for this, which wraps this crate::api::Error.

@MegaRedHand MegaRedHand merged commit 47383bf into lambdaclass:main Jun 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants