Skip to content

fix: propagate errors instead of panicking on persistence writes - #63

Merged
kacy merged 1 commit into
mainfrom
fix/propagate-persistence-write-errors
Feb 8, 2026
Merged

fix: propagate errors instead of panicking on persistence writes#63
kacy merged 1 commit into
mainfrom
fix/propagate-persistence-write-errors

Conversation

@kacy

@kacy kacy commented Feb 8, 2026

Copy link
Copy Markdown
Owner

summary

replaces ~155 .expect("vec write") calls with ? operator across the persistence layer. while Vec<u8> writes only fail on OOM, a database should never panic — it should return an error and let the caller decide.

changes:

  • AofRecord::to_bytes() return type changed from Vec<u8> to Result<Vec<u8>, FormatError>
  • updated caller in AofWriter::write_record() to propagate with ?
  • replaced .expect("vec write") with ? in AofReader::read_payload_for_tag() (already returned Result)
  • replaced .expect("vec write") with ? in SnapshotReader::read_entry() (already returned Result)

no new error variants needed — FormatError::Io already wraps io::Error via #[from].

what was tested

  • cargo build -p ember-persistence — compiles cleanly
  • cargo test --workspace — all tests pass
  • cargo clippy --workspace — no warnings

design considerations

this is a mechanical, zero-behavioral-change fix. Vec<u8> writes will continue to succeed in practice — the only difference is that an OOM now produces a clean FormatError::Io error instead of panicking the process.

replace ~155 `.expect("vec write")` calls with `?` across aof.rs and
snapshot.rs. while Vec<u8> writes only fail on OOM, a database should
never panic — it should return an error and let the caller decide.

changed `AofRecord::to_bytes()` return type from `Vec<u8>` to
`Result<Vec<u8>, FormatError>` and updated its caller in `write_record`.
the other two functions (`read_payload_for_tag`, `read_entry`) already
returned Result, so only the `.expect()` calls needed replacing.
@kacy
kacy merged commit c78f4ce into main Feb 8, 2026
5 checks passed
@kacy
kacy deleted the fix/propagate-persistence-write-errors branch February 8, 2026 19:06
kacy added a commit that referenced this pull request Feb 11, 2026
replace ~155 `.expect("vec write")` calls with `?` across aof.rs and
snapshot.rs. while Vec<u8> writes only fail on OOM, a database should
never panic — it should return an error and let the caller decide.

changed `AofRecord::to_bytes()` return type from `Vec<u8>` to
`Result<Vec<u8>, FormatError>` and updated its caller in `write_record`.
the other two functions (`read_payload_for_tag`, `read_entry`) already
returned Result, so only the `.expect()` calls needed replacing.
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.

1 participant