Skip to content

Replace unwrap/expect with proper error propagation#535

Open
dimartiro wants to merge 4 commits into
paritytech:masterfrom
ChainSafe:avoid_panics
Open

Replace unwrap/expect with proper error propagation#535
dimartiro wants to merge 4 commits into
paritytech:masterfrom
ChainSafe:avoid_panics

Conversation

@dimartiro
Copy link
Copy Markdown
Contributor

@dimartiro dimartiro commented Feb 10, 2026

Description

Replace .unwrap() and .expect() calls with proper error propagation in functions that already return Result, reducing the risk of unexpected panics in production.

This continues the work started in #509 and is also related to #350.

Copy link
Copy Markdown
Contributor

@haikoschol haikoschol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these are actually not in the webrtc transport, but AFAICT can't hurt to address them either.

@dimartiro
Copy link
Copy Markdown
Contributor Author

A lot of these are actually not in the webrtc transport, but AFAICT can't hurt to address them either.

yeah I wanted to solve as much as possible not only the ones related to webrtc

@dimartiro
Copy link
Copy Markdown
Contributor Author

@lexnv conflicts solved

@lexnv
Copy link
Copy Markdown
Collaborator

lexnv commented Jun 1, 2026

@dimartiro could you ask Claude to do a self-review on this PR to highlight the top 10 issues introduced here and try to tackle each of them 🙏

I believe this aims at tackling webrtc specific work not necesarily quic?

@dimartiro
Copy link
Copy Markdown
Contributor Author

I believe this aims at tackling webrtc specific work not necesarily quic?

@lexnv good call on the scope — I ran a self-review and you're right, this was reaching well beyond WebRTC. I've narrowed it down to WebRTC-specific work only.

dimartiro and others added 4 commits June 2, 2026 08:13
Three `.expect()` sites that upstream introduced after the original
avoid_panics commit was authored — replace with proper error
propagation so the dial/setup paths cannot panic:

- `quic/mod.rs` async dial: `make_client_config` failure now returns
  `QuicError::InvalidCertificate`; `IdleTimeout::try_from` overflow
  returns `DialError::Timeout`.
- `webrtc/mod.rs` transport setup: `Multihash::wrap` on the listener
  certificate fingerprint propagates `Error::InvalidData` instead of
  panicking on length mismatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…hanges

Per review feedback, narrow this PR to webrtc-specific work. Revert the
unwrap/expect removals in quic, s2n-quic and the shared noise codec; keep
only the changes under src/transport/webrtc/.
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.

3 participants