radicle-heartwood-lfs/crates/radicle-cli/src
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
..
commands radicle: Fix panic when reading from SQLite database fails 2025-08-25 17:05:21 +01:00
git chore: Automated fixes generated by clippy 2025-07-25 11:25:05 +02:00
terminal radicle: introduce `cob::common::Title` 2025-08-19 17:05:33 +02:00
commands.rs repo: Move workspace crates into `crates` subdirectory 2025-06-09 15:09:21 +02:00
git.rs Simplify impl of Display for some types 2025-08-19 10:57:37 +01:00
lib.rs radicle-cli: Warn when using old names of nodes 2025-06-18 16:21:21 +02:00
main.rs cli: Use human-panic 2025-08-17 20:53:53 +02:00
node.rs cli: fix error formatting 2025-08-15 11:40:25 +01:00
pager.rs repo: Move workspace crates into `crates` subdirectory 2025-06-09 15:09:21 +02:00
project.rs repo: Move workspace crates into `crates` subdirectory 2025-06-09 15:09:21 +02:00
terminal.rs radicle: improve config errors 2025-06-24 13:51:55 +02:00
warning.rs chore: Automated fixes generated by clippy 2025-07-25 11:25:05 +02:00