{"record":{"id":"06d6b7a8d7676d67","repo":"n0-computer/iroh","slug":"relayurlparseerror","errorCode":"RelayUrlParseError","errorMessage":"Failed to parse relay URL","messagePattern":"Failed to parse relay URL","errorType":"validation","errorClass":"RelayUrlParseError","httpStatus":null,"severity":"error","filePath":"iroh-base/src/relay_url.rs","lineNumber":32,"sourceCode":"/// It is encouraged to use a fully-qualified DNS domain name in the URL.  Meaning a DNS\n/// name which ends in a `.`, e.g, in `relay.example.com.`.  Otherwise the DNS resolution of\n/// your local host or network could interpret the DNS name as relative and in some\n/// configurations might cause additional delays or even connection problems.\n#[derive(\n    Clone, derive_more::Display, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,\n)]\npub struct RelayUrl(Arc<Url>);\n\nimpl From<Url> for RelayUrl {\n    fn from(url: Url) -> Self {\n        Self(Arc::new(url))\n    }\n}\n\n/// Can occur when parsing a string into a [`RelayUrl`].\n#[stack_error(derive, add_meta)]\n#[error(\"Failed to parse relay URL\")]\npub struct RelayUrlParseError(#[error(std_err)] url::ParseError);\n\n/// Support for parsing strings directly.\n///\n/// If you need more control over the error first create a [`Url`] and use [`RelayUrl::from`]\n/// instead.\nimpl FromStr for RelayUrl {\n    type Err = RelayUrlParseError;\n\n    fn from_str(s: &str) -> Result<Self, Self::Err> {\n        let inner = Url::from_str(s).map_err(RelayUrlParseError::new)?;\n        Ok(RelayUrl::from(inner))\n    }\n}\n\nimpl From<RelayUrl> for Url {\n    fn from(value: RelayUrl) -> Self {\n        Arc::unwrap_or_clone(value.0)\n    }","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/n0-computer/iroh/blob/2b4de030ce5e0133f272871a76f0c685c63f552a/iroh-base/src/relay_url.rs#L14-L50","documentation":"This is a sentinel wrapper error type (`RelayUrlParseError`) raised by `RelayUrl::from_str` when the input string cannot be parsed as a valid URL by the `url` crate (`Url::from_str` fails with a `url::ParseError`, e.g. missing scheme, invalid characters, or a malformed host). The faulting input is the string being parsed into a `RelayUrl`; it must be an absolute URL such as `https://relay.example.com/` to succeed.","triggerScenarios":"Calling \"...\".parse::<RelayUrl>() or RelayUrl::from_str with a malformed URL string (missing scheme, invalid characters, unparseable host) that the url crate's parser rejects.","commonSituations":"Relay addresses in config files or env vars with typos or missing https:// prefix, user-supplied relay URLs from CLI args, trimmed/whitespace-corrupted values, IPv6 hosts without brackets.","solutions":["Fix the URL string so it is a fully qualified valid URL, e.g. \"https://relay.example.com\".","Validate with url::Url::parse first to get a detailed parse-error message.","Check config/env sources for typos, whitespace, or missing scheme.","Build the RelayUrl from a validated Url (RelayUrl::from) if you need custom control."],"exampleFix":"// before\nlet relay: RelayUrl = \"relay.example.com\".parse()?; // missing scheme\n// after\nlet relay: RelayUrl = \"https://relay.example.com\".parse()?;","handlingStrategy":"validation","validationCode":"fn parse_relay_url(s: &str) -> Result<RelayUrl, url::ParseError> {\n    let u = url::Url::parse(s)?;\n    Ok(RelayUrl::from(u))\n}","typeGuard":"fn is_parseable_url(s: &str) -> bool { url::Url::parse(s).is_ok() }","tryCatchPattern":"match s.parse::<RelayUrl>() {\n    Err(RelayUrlParseError(e)) => bail!(\"bad relay url '{s}': {e}\"),\n    Ok(u) => u,\n}","preventionTips":["Require scheme (https://) in relay config values.","Trim whitespace from user/config-supplied URLs.","Validate relay URLs at startup, not on first use.","Prefer Url::parse first for a detailed error message."],"tags":["url","parsing","relay","configuration"],"backgroundTag":"invalid-url-format","analyzedSha":"2b4de030ce5e0133f272871a76f0c685c63f552a","analyzedAt":"2026-09-08T04:26:47.755Z","contentChangedAt":"2026-09-08T04:26:47.755Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}