Skip to content

[desktop/macos] Backend-Rust: unwraps in request paths, no panic-catch layer, no clippy/cargo-test in CI #8847

Closed

Description

@Git-on-my-level

Area: Rust backend robustness

Problem

The desktop Rust backend serves real user traffic (auth, LLM proxy, Firestore) but has three compounding gaps:

  1. Panics in request paths. 189 unwrap() lines under src/routes/ (many in #[cfg(test)], but prod-path examples exist): routes/proxy.rs:238 and :518 (byok_gemini_key.unwrap() — currently guarded by an early return above, but the invariant is positional and will break under refactor), routes/screen_activity.rs:55 (firestore_result.unwrap() after an if let Err check — same pattern), and Response::builder()...unwrap() in chat_completions.rs:592/751/798/1067, proxy.rs:544/655, tts.rs:212.
  2. No CatchPanicLayer. src/main.rs:333-358 layers auth/paywall/BYOK/CORS/trace but nothing catches handler panics — a panic drops the connection with no 500 and no structured log.
  3. CI runs cargo check only. .github/workflows/lint.yml runs rustfmt + cargo check --locked for desktop Rust changes; cargo test runs only in local test.sh and the narrow desktop-backend-contracts.yml (cargo test ... contract). No clippy anywhere. Cargo.toml has no [lints] section.

Suggested fix

  1. Add tower_http::catch_panic::CatchPanicLayer to the router (one line, converts panics to 500s + log).
  2. Add to Cargo.toml: [lints.clippy] unwrap_used = "deny", expect_used = "warn" (with #[allow] in test modules), then convert the handful of prod-path unwraps to ?/match — the two byok_key sites become let Some(byok_key) = byok_gemini_key else { return internal_error(...) }.
  3. Extend the lint.yml desktop-rust step: cargo clippy --locked -- -D warnings and cargo test --locked (it already has the toolchain + cache set up; incremental cost is small).

Positive pattern worth protecting

desktop-backend-contracts.yml (contract tests on every relevant PR) is exactly the right shape — this issue just widens the same gate.

Activity

  1. added
    bug
    on Jul 2, 2026
  2. added
    retrieval-action
    p2
    on Jul 4, 2026
  3. undivisible commented on Jul 19, 2026

    @undivisible
    Collaborator

    Verified fixed on main by 8c3105d and d0453a1. Backend-Rust installs CatchPanicLayer, production-path unwraps were hardened, and .github/workflows/desktop-backend-rust.yml runs locked clippy and cargo test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2refactorretrieval-action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions