Hmbown/CodeWhale · error
The Codewhale service returned a verification URL without a…
Error message
The Codewhale service returned a verification URL without a host
What it means
During Codewhale device login, the CLI parses the verification URL returned by the service and requires it to have a host. If `Url::parse` succeeds but `url.host_str()` is None (e.g. a scheme-only URL like `https:`), the CLI refuses it because it could not validate where the user would be sent.
Solutions
- Retry `codewhale login`; the URL is returned by the service, so a transient bad response may self-heal.
- Check whether a corporate proxy or API gateway rewrites response bodies.
- Upgrade `codewhale` and report the issue to the Codewhale service team if it persists.
Defensive patterns
Strategy: validation
Validate before calling
let url = url::Url::parse(value)?;
if url.host_str().is_none() {
return Err("service returned a URL without a host");
} Type guard
fn has_host(s: &str) -> bool {
url::Url::parse(s).map(|u| u.host_str().is_some()).unwrap_or(false)
} Prevention
- Validate URLs from the service before presenting them to users.
- Report persistently malformed login URLs to the service team.
- Pin/upgrade CLI versions after backend URL-format changes.
When it happens
Trigger: The cloud API's authorize/verification endpoint returned a malformed or scheme-only URL string (or an empty/opaque URL) in its JSON response, and the CLI tried to resolve its host for the browser-verification step.
Common situations: A backend bug or gateway/proxy rewriting the login response; a misconfigured service returning placeholder URLs; corrupted or truncated API responses during `codewhale login`.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- Not signed in. Run `codewhale account login` first
- The Codewhale account session expired. Run `codewhale…
- a Gitee access token is not configured in the Codewhale…
- --base-url must use http or https
- browser URL cannot be empty
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/79bdaae5edd3f660.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/cloud.rs:1052
}
url.set_path("/");
let display = url.as_str().trim_end_matches('/').to_string();
Ok(ValidatedApiBase { url, display })
}
fn validate_verification_url(
value: &str,
api_base: &str,
user_code: &str,
complete: bool,
) -> Result<String> {
let url =
Url::parse(value).context("The Codewhale service returned an invalid verification URL")?;
if value != url.as_str() {
bail!("The Codewhale service returned an unsafe verification URL");
}
let host = url.host_str().ok_or_else(|| {
anyhow!("The Codewhale service returned a verification URL without a host")
})?;
if !url.username().is_empty() || url.password().is_some() || url.fragment().is_some() {
bail!("The Codewhale service returned an unsafe verification URL");
}
if url.path() != "/cli/authorize" {
bail!("The Codewhale service returned an unsafe verification URL");
}
let api = Url::parse(api_base).context("invalid Codewhale account API base URL")?;
let canonical_api = api.scheme() == "https"
&& api.host_str() == Some("api.codewhale.net")
&& api.port_or_known_default() == Some(443);
let loopback_api = api.host_str().is_some_and(is_loopback_host);
if canonical_api {
if url.scheme() != "https"
|| !host.eq_ignore_ascii_case("app.codewhale.net")
|| url.port_or_known_default() != Some(443)
{View on GitHub (pinned to 73e0f67d83)