Hmbown/CodeWhale · error

invalid download url

Error message

invalid download url: {url}

What it means

Inside `download_first_success`, each candidate URL is host-parsed so the network policy can decide allow/deny/prompt. A URL without a parsable host cannot be evaluated and is rejected outright rather than skipped.

Solutions

  1. Prefix the URL with its scheme (`https://`) in the registry entry or source
  2. Validate URLs with a host-extraction check before building the source list
  3. Fix the registry JSON entry that produced the malformed URL

Example fix

// before
InstallSource::DirectUrl("example.com/skill.tar.gz".into())
// after
InstallSource::DirectUrl("https://example.com/skill.tar.gz".into())
Defensive patterns

Strategy: validation

Validate before calling

fn has_host(u: &str) -> bool {
    url::Url::parse(u).map(|p| p.host_str().is_some()).unwrap_or(false)
}

Prevention

When it happens

Trigger: Calling any install/update path whose resolved URL list contains a non-absolute or scheme-less URL — typically a registry entry or `InstallSource::DirectUrl` holding `"example.com/pkg.tar.gz"` without `https://`.

Common situations: Registry JSON with scheme-less URLs; hand-edited direct URLs missing the scheme; concatenation bugs building URLs from config fragments.

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


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/8df450eaa6c5d2ba. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/skills/install.rs:1100

        }
    }
}

/// Download the first URL whose host the policy allows and which returns 2xx.
/// Returns `NeedsApproval` if every candidate hit `Prompt`, or `Denied` if every
/// candidate was denied.
async fn download_first_success(
    urls: &[String],
    network: &NetworkPolicy,
    max_size: u64,
) -> Result<DownloadOutcome> {
    let mut last_status: Option<reqwest::StatusCode> = None;
    let mut prompt_host: Option<String> = None;
    let mut denied_host: Option<String> = None;
    for url in urls {
        let host = match host_from_url(url) {
            Some(h) => h,
            None => bail!("invalid download url: {url}"),
        };
        match network.decide(&host) {
            Decision::Allow => {}
            Decision::Deny => {
                denied_host.get_or_insert(host);
                continue;
            }
            Decision::Prompt => {
                prompt_host.get_or_insert(host);
                continue;
            }
        }
        match download_with_cap(url, max_size).await? {
            DownloadAttempt::Bytes(bytes) => {
                return Ok(DownloadOutcome::Bytes {
                    bytes,
                    url: url.clone(),
                });

View on GitHub (pinned to 73e0f67d83)