{"record":{"id":"9ac271995315fc27","repo":"GitoxideLabs/gitoxide","slug":"host-is-present-in-url","errorCode":null,"errorMessage":"host is present in url","messagePattern":"host is present in url","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-transport/src/client/async_io/connect.rs","lineNumber":30,"sourceCode":"    /// Use `options` to further control specifics of the transport resulting from the connection.\n    pub async fn connect<Url, E>(url: Url, options: super::Options) -> Result<Box<dyn Transport + Send>, Error>\n    where\n        Url: TryInto<gix_url::Url, Error = E>,\n        gix_url::parse::Error: From<E>,\n    {\n        let mut url = url.try_into().map_err(gix_url::parse::Error::from)?;\n        Ok(match url.scheme {\n            gix_url::Scheme::Git => {\n                if url.user().is_some() {\n                    return Err(Error::UnsupportedUrlTokens {\n                        url: url.to_bstring(),\n                        scheme: url.scheme,\n                    });\n                }\n                let path = std::mem::take(&mut url.path);\n                Box::new(\n                    Connection::new_tcp(\n                        url.host().expect(\"host is present in url\"),\n                        url.port,\n                        path,\n                        options.version,\n                        options.trace,\n                    )\n                    .await\n                    .map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?,\n                )\n            }\n            scheme => return Err(Error::UnsupportedScheme(scheme)),\n        })\n    }\n}\n\n#[cfg(feature = \"async-std\")]\npub use function::connect;\n","sourceCodeStart":12,"sourceCodeEnd":47,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-transport/src/client/async_io/connect.rs#L12-L47","documentation":"Panic from `url.host().expect(\"host is present in url\")` while establishing an async TCP (`git://`) connection in gix-transport. The library assumes any URL using a scheme that reaches this branch (git protocol) carries a host, because URL parsing normally enforces it. If the host is somehow absent the connection setup panics rather than returning a parse error.","triggerScenarios":"Calling `gix::protocol::connect` (async) with a `git://` URL whose host component is empty or missing, e.g. `git://` or `git:///path`, slipping past validation.","commonSituations":"Hand-built or truncated remote URLs in configuration; programmatic URL construction that omits the host; unusual URL forms that parsers did not reject.","solutions":["Use a well-formed URL including a host, e.g. `git://example.com/repo.git`.","Validate the URL before connecting (parse it and check `host()` is `Some`).","Prefer cloning from the remote's advertised URL rather than retyping it.","Upgrade gix-transport/gix in case parsing has changed to allow host-less git URLs."],"exampleFix":"// before\nlet remote = repo.remote(\"origin\").url().expect(...); // \"git:///repo.git\" (no host)\n// after\nassert url starts with \"git://\" and has a non-empty host before connect:\nlet parsed = gix_url::parse(url.as_bytes())?;\nassert!(parsed.host.is_some(), \"git URLs require a host\");","handlingStrategy":"validation","validationCode":"let parsed = gix_url::parse(url.as_bytes())?;\nif parsed.host.is_none() {\n    anyhow::bail!(\"git:// URL requires a host: {url}\");\n}","typeGuard":"fn has_host(u: &gix_url::Url) -> bool {\n    u.host.is_some()\n}","tryCatchPattern":"match std::panic::catch_unwind(AssertUnwindSafe(|| connect(url))) {\n    Ok(c) => c,\n    Err(_) => anyhow::bail!(\"connect panicked: URL missing host\"),\n}","preventionTips":["Validate URLs with gix-url before passing to transport APIs","Copy remote URLs from git config rather than typing them","Prefer https:// URLs, whose parsing enforces host presence"],"tags":["rust","panic","url","network","git-protocol"],"backgroundTag":"invalid-url","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}