fix: Replace unwrap with proper error handling in WebSocket subscribe handler#4696
Open
Shiven0504 wants to merge 1 commit intoclockworklabs:masterfrom
Open
fix: Replace unwrap with proper error handling in WebSocket subscribe handler#4696Shiven0504 wants to merge 1 commit intoclockworklabs:masterfrom
Shiven0504 wants to merge 1 commit intoclockworklabs:masterfrom
Conversation
… handler `get_database_by_identity()` was the only call site using `.unwrap()` instead of `.map_err(log_and_500)?`, which could panic the server on a transient database error during WebSocket connection setup. Closes clockworklabs#4686
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Replace
.unwrap()with.map_err(log_and_500)?on theget_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 indatabase.rsalready 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
get_database_by_identitycall siteslog_and_500is already imported in the file