vectordotdev/vector · error
should not fail to build URI
Error message
should not fail to build URI
What it means
`GrpcAddress::as_uri` builds an http:// URI from a SocketAddr with scheme, authority, and a fixed "/" path. Since both parts come from a well-formed SocketAddr, construction cannot fail in practice, so failure is asserted with `expect("should not fail to build URI")`.
Solutions
- Verify no custom Display/ToSocketAddrs wrapper alters the address string before URI construction.
- Update the http crate if a version bug rejects valid authority strings.
- File an upstream bug with the address value if you can reproduce a failure with a standard SocketAddr.
Defensive patterns
Strategy: fallback
Validate before calling
let uri = http::Uri::builder().scheme("http").authority(addr.to_string()).path_and_query("/").build(); assert!(uri.is_ok(), "address {:?} did not produce a valid URI", addr); Type guard
fn is_valid_authority(addr: &SocketAddr) -> bool { !addr.to_string().is_empty() && addr.to_string().len() < 256 } Try / catch
match build_uri(addr) { Ok(uri) => uri, Err(e) => { log::error!("URI build failed: {e}"); return; } } // if you own the code; otherwise this is an upstream bug Prevention
- Use standard SocketAddr values from Tokio's bind/connect results.
- Keep the http crate up to date.
- Add a unit test asserting as_uri succeeds for IPv4 and IPv6 loopback addresses.
When it happens
Trigger: Calling `as_uri` (directly or via build_output_edge, from_address, or attach_to_config) with an address whose string form is rejected by `http::Uri` building — practically only from a corrupted/oversized SocketAddr string.
Common situations: Setting up the validation gRPC output edge during vector validate runs; exotic SocketAddr implementations; IPv6 addresses rendering in an unexpected form after custom Display overrides.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- a valid HTTP/1 URI is valid as an HTTP URI
- a validated HTTP endpoint is a valid `http 1` URI
- all-of subschemas must be present here
- can't run runner twice
- could not parse path
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/1ffb358c87a90a3c.
Report an issue: GitHub.
Appendix: source
Thrown at src/components/validation/util.rs:34
/// Gets the socket address.
///
/// This is typically used when actually binding a socket to use for listening for connections
/// as a gRPC server.
pub const fn as_socket_addr(&self) -> SocketAddr {
self.addr
}
/// Gets the fully-qualified endpoint address.
///
/// This is a URI in the form of `http://<socket address>/`. The scheme and path are hard-coded.
pub fn as_uri(&self) -> Uri {
let addr_str = self.addr.to_string();
Uri::builder()
.scheme("http")
.authority(addr_str)
.path_and_query("/")
.build()
.expect("should not fail to build URI")
}
}
impl From<SocketAddr> for GrpcAddress {
fn from(addr: SocketAddr) -> Self {
Self { addr }
}
}
impl fmt::Display for GrpcAddress {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.addr.fmt(f)
}
}
View on GitHub (pinned to bdb87aeaa4)