Replace .unwrap() with proper error handling in HTTP handlers #16

Open
opened 2026-07-25 11:18:28 +00:00 by GKaszewski · 0 comments
Owner

Severity: Medium

crates/presentation/src/handlers/thoughts.rs — two places call .unwrap() on serialization in request handlers:

// get_thought_handler (~line 70)
serde_json::to_value(to_thought_response(&entry)).unwrap()

// get_thread_handler (~line 95)
.map(|e| serde_json::to_value(to_thought_response(e)).unwrap())

If serialization fails for any reason, this panics and kills the request with a 500 instead of returning a proper error. Propagate with ? or .map_err().

**Severity: Medium** `crates/presentation/src/handlers/thoughts.rs` — two places call `.unwrap()` on serialization in request handlers: ```rust // get_thought_handler (~line 70) serde_json::to_value(to_thought_response(&entry)).unwrap() // get_thread_handler (~line 95) .map(|e| serde_json::to_value(to_thought_response(e)).unwrap()) ``` If serialization fails for any reason, this panics and kills the request with a 500 instead of returning a proper error. Propagate with `?` or `.map_err()`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GKaszewski/thoughts#16