Skip to content

Comments

Preserve URI parse error info in error source chain#4025

Open
veeceey wants to merge 1 commit intohyperium:masterfrom
veeceey:fix/issue-3043-preserve-uri-error-info
Open

Preserve URI parse error info in error source chain#4025
veeceey wants to merge 1 commit intohyperium:masterfrom
veeceey:fix/issue-3043-preserve-uri-error-info

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 23, 2026

Fixes #3043

When hyper parsed an HTTP request with an invalid URI, it would create a Parse(Uri) error but discard the original http::uri::InvalidUri error. This meant error.source() returned None, making it impossible to get the actual reason the URI was invalid.

Changed Parse::Uri to carry an Option<Cause> so the original InvalidUri or InvalidUriParts error flows through to Error::source(). The error message and Display output are unchanged - the improvement is only visible through the Error::source() chain.

Added a test that verifies error.source() returns the original http::uri::InvalidUri:

running 86 tests
...
test error::tests::uri_error_preserves_source ... ok
...
test result: ok. 86 passed; 0 failed; 0 ignored

When an invalid URI is parsed by the http crate, the InvalidUri error
contains useful details about what part of the URI was invalid. Previously
this information was discarded when converting to hyper::Error.

Now the original InvalidUri/InvalidUriParts error is stored as the
source of the hyper::Error, making it available through the standard
Error::source() chain and downcastable to the concrete type.

Closes hyperium#3043
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.

URI parse errors should preserve information from the HTTP crate

1 participant