GitoxideLabs/gitoxide · error
host is present in url
Error message
host is present in url
What it means
The blocking (sync) counterpart of the async git-protocol connect: `url.host().expect("host is present in url")` panics when a `git://` URL without a host reaches the file-transport connect path. gix-transport assumes URL parsing guarantees a host for these schemes; violating that assumption aborts the process instead of returning an error.
Solutions
- Fix the URL to include the host: `git://host.tld/path.git`.
- Validate with a URL parse (check `host` is present) before invoking connect.
- If the URL should be local, use a `file://` or plain path instead of `git://`.
- Update gix-transport if a regression allowed host-less git URLs to parse.
Example fix
// before url = "git:///repo.git"; // missing host // after url = "git://github.com/user/repo.git";
Defensive patterns
Strategy: validation
Validate before calling
let parsed = gix_url::parse(url.as_bytes())?;
if parsed.scheme == gix_url::Scheme::Git && parsed.host.is_none() {
anyhow::bail!("git URL missing host");
} Type guard
fn connectable(u: &gix_url::Url) -> bool {
!matches!(u.scheme, gix_url::Scheme::Git) || u.host.is_some()
} Try / catch
let r = std::panic::catch_unwind(AssertUnwindSafe(|| blocking_connect(url)));
if r.is_err() { anyhow::bail!("connection aborted: URL lacked host"); } Prevention
- Check .git/config remote URLs for truncation before connect
- Use file paths for local repos instead of git:// with empty host
- Run URL validation in config-loading code
When it happens
Trigger: Calling the blocking connect API with a `git://` URL lacking a host component (e.g. `git://` with empty host).
Common situations: Malformed `remote.origin.url` entries in `.git/config`, copy-paste truncation of URLs, or programmatic URL assembly that dropped the host.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- host is present in url
- valid url
- ' ' is not a valid configuration key
- Cannot use iter_v1() on index of type
- Cannot use iter_v2() on index of type
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/b80b3ab1b6f64762.
Report an issue: GitHub.
Appendix: source
Thrown at gix-transport/src/client/blocking_io/connect.rs:55
crate::client::blocking_io::file::connect(url.path, options.version, options.trace)
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?,
)
}
gix_url::Scheme::Ssh => Box::new({
crate::client::blocking_io::ssh::connect(url, options.version, options.ssh, options.trace)
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?
}),
gix_url::Scheme::Git => {
if url.user().is_some() {
return Err(Error::UnsupportedUrlTokens {
url: url.to_bstring(),
scheme: url.scheme,
});
}
Box::new({
let path = std::mem::take(&mut url.path);
crate::client::git::blocking_io::connect(
url.host().expect("host is present in url"),
path,
options.version,
url.port,
options.trace,
)
.map_err(|e| Box::new(e) as Box<dyn std::error::Error + Send + Sync>)?
})
}
#[cfg(not(any(feature = "http-client-curl", feature = "http-client-reqwest")))]
gix_url::Scheme::Https | gix_url::Scheme::Http => return Err(Error::CompiledWithoutHttp(url.scheme)),
#[cfg(feature = "http-client-curl")]
gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(
crate::client::blocking_io::http::connect::<Curl>(url, options.version, options.trace),
),
#[cfg(all(feature = "http-client-reqwest", not(feature = "http-client-curl")))]
gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect::<
Reqwest,
>(View on GitHub (pinned to e73179060b)