Skip to content

Commit 44ef7f4

Browse files
authored
fix: Replace unwrap with proper error handling in WebSocket subscribe handler (#4696)
# Description of Changes Replace `.unwrap()` with `.map_err(log_and_500)?` on the `get_database_by_identity()` call in the WebSocket subscribe handler (`crates/client-api/src/routes/subscribe.rs`). This was the only call site in the codebase using `.unwrap()` for this method — all four other call sites in `database.rs` already use `.map_err(log_and_500)?`. A transient database error during WebSocket connection setup would panic the server instead of returning an HTTP 500. Closes #4686 # API and ABI breaking changes None. # Expected complexity level and risk 1 — Single-token replacement matching the established pattern used everywhere else. # Testing - [ ] Verified the fix matches the error-handling pattern used at all other `get_database_by_identity` call sites - [ ] Confirmed `log_and_500` is already imported in the file
1 parent 18f6da6 commit 44ef7f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/client-api/src/routes/subscribe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189
let database = ctx
190190
.get_database_by_identity(&db_identity)
191191
.await
192-
.unwrap()
192+
.map_err(log_and_500)?
193193
.ok_or(StatusCode::NOT_FOUND)?;
194194

195195
let leader = ctx.leader(database.id).await.map_err(log_and_500)?;

0 commit comments

Comments
 (0)