zed-industries/zed · error
failed to get host from bitbucket base url
Error message
failed to get host from bitbucket base url
What it means
fetch_bitbucket_commit_author builds an API URL from the provider's configured base URL; if url::Url::host_str() returns None, the URL has no host component (non-HTTP scheme, relative URL, or malformed parse) and the provider cannot construct a request, so it bails immediately.
Source
Thrown at crates/git_hosting_providers/src/providers/bitbucket.rs:116
Url::parse(&format!("https://{}", host))?,
))
}
fn is_self_hosted(&self) -> bool {
self.base_url
.host_str()
.is_some_and(|host| host != "bitbucket.org")
}
async fn fetch_bitbucket_commit_author(
&self,
repo_owner: &str,
repo: &str,
commit: &str,
client: &Arc<dyn HttpClient>,
) -> Result<Option<String>> {
let Some(host) = self.base_url.host_str() else {
bail!("failed to get host from bitbucket base url");
};
let is_self_hosted = self.is_self_hosted();
let url = if is_self_hosted {
format!(
"https://{host}/rest/api/latest/projects/{repo_owner}/repos/{repo}/commits/{commit}?avatarSize=128"
)
} else {
format!("https://api.{host}/2.0/repositories/{repo_owner}/{repo}/commit/{commit}")
};
let request = Request::get(&url)
.header("Content-Type", "application/json")
.follow_redirects(http_client::RedirectPolicy::FollowAll);
let mut response = client
.send(request.body(AsyncBody::default())?)
.await
.with_context(|| format!("error fetching BitBucket commit details at {:?}", url))?;View on GitHub (pinned to f4178619ac)
Solutions
- Validate the base URL when constructing the provider: require scheme http/https and a non-empty host.
- Use Bitbucket::public_instance() for bitbucket.org and Bitbucket::from_remote_url() for self-hosted instances — both build well-formed URLs.
- Log the offending base_url at construction time so misconfiguration is caught early.
- Reject hostless URLs with a clear configuration error instead of failing later at fetch time.
Example fix
// before
Ok(Self::new(name, base_url))
// after
anyhow::ensure!(
matches!(base_url.scheme(), "http" | "https") && base_url.host_str().is_some(),
"BitBucket base URL must be an absolute HTTP(S) URL with a host: {base_url}"
);
Ok(Self::new(name, base_url)) Defensive patterns
Strategy: validation
Validate before calling
fn valid_http_url(url: &Url) -> bool {
matches!(url.scheme(), "http" | "https") && url.host_str().is_some()
}
anyhow::ensure!(valid_http_url(&base_url), "base URL must be absolute HTTP(S) with a host"); Type guard
fn has_host(url: &Url) -> bool {
url.host_str().map(|h| !h.is_empty()).unwrap_or(false)
} Try / catch
if let Err(e) = provider.commit_author(..).await {
if e.to_string().contains("failed to get host") {
// configuration bug: rebuild the provider from a validated URL
}
return Err(e);
} Prevention
- Validate provider base URLs (scheme http/https + host) once at construction, not per request.
- Construct providers via from_remote_url()/public_instance() instead of hand-building URLs.
- Fail fast on malformed instance URLs in configuration with the offending value in the message.
When it happens
Trigger: Constructing a Bitbucket provider with a base Url whose host is None — for example a Url parsed from unexpected input (a `file:` or relative URL) or a default-constructed Url — and then triggering commit-author lookup.
Common situations: Providers created from user-configured instance URLs or remote URLs that parsed into something hostless; partially initialized config; URL normalization stripping the host (leading slash, missing scheme before a colon-containing path).
Related errors
- extension dir {} is not an absolute path
- path dataset requires data_dir
- unsupported TOML value in .env.toml for key {}
- unsupported MCP url scheme {}
- Zed cannot determine how to run this debug scenario. `build`
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/09e3ccfebe1d65dc.
Report an issue: GitHub.