{"record":{"id":"8df450eaa6c5d2ba","repo":"Hmbown/CodeWhale","slug":"invalid-download-url-url","errorCode":null,"errorMessage":"invalid download url: {url}","messagePattern":"invalid download url: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/install.rs","lineNumber":1100,"sourceCode":"        }\n    }\n}\n\n/// Download the first URL whose host the policy allows and which returns 2xx.\n/// Returns `NeedsApproval` if every candidate hit `Prompt`, or `Denied` if every\n/// candidate was denied.\nasync fn download_first_success(\n    urls: &[String],\n    network: &NetworkPolicy,\n    max_size: u64,\n) -> Result<DownloadOutcome> {\n    let mut last_status: Option<reqwest::StatusCode> = None;\n    let mut prompt_host: Option<String> = None;\n    let mut denied_host: Option<String> = None;\n    for url in urls {\n        let host = match host_from_url(url) {\n            Some(h) => h,\n            None => bail!(\"invalid download url: {url}\"),\n        };\n        match network.decide(&host) {\n            Decision::Allow => {}\n            Decision::Deny => {\n                denied_host.get_or_insert(host);\n                continue;\n            }\n            Decision::Prompt => {\n                prompt_host.get_or_insert(host);\n                continue;\n            }\n        }\n        match download_with_cap(url, max_size).await? {\n            DownloadAttempt::Bytes(bytes) => {\n                return Ok(DownloadOutcome::Bytes {\n                    bytes,\n                    url: url.clone(),\n                });","sourceCodeStart":1082,"sourceCodeEnd":1118,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/install.rs#L1082-L1118","documentation":"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.","triggerScenarios":"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://`.","commonSituations":"Registry JSON with scheme-less URLs; hand-edited direct URLs missing the scheme; concatenation bugs building URLs from config fragments.","solutions":["Prefix the URL with its scheme (`https://`) in the registry entry or source","Validate URLs with a host-extraction check before building the source list","Fix the registry JSON entry that produced the malformed URL"],"exampleFix":"// before\nInstallSource::DirectUrl(\"example.com/skill.tar.gz\".into())\n// after\nInstallSource::DirectUrl(\"https://example.com/skill.tar.gz\".into())","handlingStrategy":"validation","validationCode":"fn has_host(u: &str) -> bool {\n    url::Url::parse(u).map(|p| p.host_str().is_some()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Require absolute https URLs in registry entries and direct sources","Validate URLs before constructing InstallSource","Strip whitespace from config-provided URLs"],"tags":["download","url","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}