radicle-heartwood-lfs/crates/radicle-protocol/src/service
Lorenz Leutgeb 192cc993a8 radicle: Fix panic when reading from SQLite database fails
I was greeted by `rad patch redact` with

    called `Result::unwrap()` on an `Err` value:

      Error { code: None, message: Some("failed to convert") }

    stack backtrace:

    […]
       3: core::result::Result<T,E>::unwrap
             at …/rust-1.88.0/lib/rustlib/src/rust/library/core/src/result.rs:1137:23
       4: sqlite::cursor::Row::read
             at …/index.crates.io-1949cf8c6b5b557f/sqlite-0.32.0/src/cursor.rs:136:9
       5: radicle::cob::patch::cache::query::find_by_revision
             at ./crates/radicle/src/cob/patch/cache.rs:624:65
       6: <… as radicle::cob::patch::cache::Patches>::find_by_revision
             at ./crates/radicle/src/cob/patch/cache.rs:553:9
       7: radicle_cli::commands::rad_patch::redact::run
             at ./crates/radicle-cli/src/commands/patch/redact.rs:23:9
       8: radicle_cli::commands::rad_patch::run
             at ./crates/radicle-cli/src/commands/patch.rs:1026:13
    […]

It turns out that `sqlite::cursor::Row::read` is the panicky version of
`sqlite::cursor::Row::try_read` (which returns a `Result`).

While it is somewhat rare that SQLite reads fail, it is not unheard of.
In `radicle-cli` it might not be critical, but also `radicle-protocol`
and `radicle-fetch` are affected, and they could potentially panic a
`radicle-node` process.

Use `try_read` instead, and propagate down the error handling.
2025-08-25 17:05:21 +01:00
..
gossip radicle: Fix panic when reading from SQLite database fails 2025-08-25 17:05:21 +01:00
filter.rs radicle: Fix panic when reading from SQLite database fails 2025-08-25 17:05:21 +01:00
gossip.rs chore: Automated fixes generated by clippy 2025-07-25 11:25:05 +02:00
io.rs node, protocol: Refactor 2025-07-16 21:15:52 +02:00
limiter.rs protocol: Create skeleton by moving from radicle-node 2025-07-16 21:12:42 +02:00
message.rs protocol: Refactor decoding 2025-08-25 11:57:44 +01:00
session.rs radicle/config/node: Use newtypes 2025-08-19 13:16:19 +02:00