Skip to content

Replace panics with proper error returns#228

Merged
rgbkrk merged 1 commit intomasterfrom
test-hardening-review
Mar 4, 2026
Merged

Replace panics with proper error returns#228
rgbkrk merged 1 commit intomasterfrom
test-hardening-review

Conversation

@rgbkrk
Copy link
Copy Markdown
Member

@rgbkrk rgbkrk commented Feb 25, 2026

Summary

Replace production panics with proper error handling to prevent crashes on malformed messages and invalid internal states.

  • router.rs: Return ZmqError::Socket when ROUTER send receives <2 frames (was assert!)
  • backend.rs: Return errors for Greeting/Command message types instead of panicking
  • sub.rs: Log and handle subscription send failures instead of unwrapping
  • pub.rs, xpub.rs: Safely validate first frame exists before subscription matching

- router.rs: return ZmqError::Socket instead of assert! for malformed messages
- backend.rs: return errors instead of panic! for Greeting/Command messages
- sub.rs: log and return early on subscription send failure instead of unwrap
- pub.rs, xpub.rs: safely extract first frame before subscription matching
- add tests for router error paths
@rgbkrk rgbkrk merged commit 499b50d into master Mar 4, 2026
3 checks passed
@rgbkrk rgbkrk deleted the test-hardening-review branch March 4, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant