Skip to content

Raise OSError for UDP server startup failures - #323

Open
Sonike wants to merge 1 commit into
mitmproxy:mainfrom
Sonike:fix/socket-bind-oserror
Open

Raise OSError for UDP server startup failures#323
Sonike wants to merge 1 commit into
mitmproxy:mainfrom
Sonike:fix/socket-bind-oserror

Conversation

@Sonike

@Sonike Sonike commented Aug 23, 2026

Copy link
Copy Markdown

Summary

  • convert std::io::Errors wrapped by anyhow into Python OSErrors at the UDP and WireGuard server boundaries
  • preserve the raw OS errno so mitmproxy can recognize EADDRINUSE and show its existing actionable port suggestion
  • add a regression test using a real address-in-use error and document the change

Fixes mitmproxy/mitmproxy#7650.

Test plan

  • cargo fmt --all --check
  • cargo clippy -p mitmproxy_rs --all-targets -- -D warnings
  • cargo test -p mitmproxy_rs

This change was prepared with Codex assistance and verified locally.

@mhils mhils left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the great PR! 😃

Comment thread mitmproxy-rs/src/util.rs
}

/// Convert I/O errors wrapped by anyhow into Python OSErrors, preserving errno.
pub fn anyhow_to_pyerr(error: anyhow::Error) -> PyErr {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we rename this to ioerror_to_oserror or something like this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed — ioerror_to_oserror is clearer. I'll rename it. Thanks!

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.

Better error message for WireGuard port conflict

2 participants