{"record":{"id":"8b4d3dc218c3d339","repo":"Hmbown/CodeWhale","slug":"codewhale-account-api-base-url-must-include-a-host","errorCode":null,"errorMessage":"Codewhale account API base URL must include a host","messagePattern":"Codewhale account API base URL must include a host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/cloud.rs","lineNumber":1028,"sourceCode":"struct ValidatedApiBase {\n    url: Url,\n    display: String,\n}\n\nfn validate_api_base(value: &str) -> Result<ValidatedApiBase> {\n    let mut url = Url::parse(value.trim()).context(\"invalid Codewhale account API base URL\")?;\n    if !url.username().is_empty() || url.password().is_some() {\n        bail!(\"Codewhale account API base URL must not contain credentials\");\n    }\n    if url.query().is_some() || url.fragment().is_some() {\n        bail!(\"Codewhale account API base URL must not contain a query or fragment\");\n    }\n    if !matches!(url.path(), \"\" | \"/\") {\n        bail!(\"Codewhale account API base URL must be an origin without a path\");\n    }\n    let host = url\n        .host_str()\n        .ok_or_else(|| anyhow!(\"Codewhale account API base URL must include a host\"))?;\n    let allowed = url.scheme() == \"https\" || (url.scheme() == \"http\" && is_loopback_host(host));\n    if !allowed {\n        bail!(\n            \"Codewhale account API base URL must use HTTPS (loopback HTTP is allowed for testing)\"\n        );\n    }\n    url.set_path(\"/\");\n    let display = url.as_str().trim_end_matches('/').to_string();\n    Ok(ValidatedApiBase { url, display })\n}\n\nfn validate_verification_url(\n    value: &str,\n    api_base: &str,\n    user_code: &str,\n    complete: bool,\n) -> Result<String> {\n    let url =","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/cloud.rs#L1010-L1046","documentation":"Thrown while validating the Codewhale account API base URL. After confirming the URL has no path, the validator requires a host component; a URL that parsed but has no host (e.g. a scheme-relative or opaque URL) cannot be used as an API origin, so this error is raised before the HTTPS/loopback scheme check.","triggerScenarios":"Configuring the Codewhale account API base URL with a value that has no host — e.g. `\"https://\"`, an empty/whitespace-derived parse, or an incorrectly formed URL string.","commonSituations":"Typo or truncated URL in config; env var interpolation leaving an empty value; copy-paste dropping the hostname; using a bare scheme without authority.","solutions":["Set the base URL to a full origin such as `https://api.example.com` (scheme + host, no path).","Check the config file/env var for truncation or empty interpolation producing `https://`.","Ensure HTTPS is used (loopback HTTP is permitted only for local testing)."],"exampleFix":"// before\napi_base_url = \"https://\"\n// after\napi_base_url = \"https://api.codewhale.dev\"","handlingStrategy":"validation","validationCode":"let u = url::Url::parse(base)?;\nif u.host_str().is_none() || !matches!(u.path(), \"\" | \"/\") { bail!(\"base URL must be an origin with a host\"); }","typeGuard":"fn is_valid_origin(u: &url::Url) -> bool {\n    u.host_str().is_some() && matches!(u.path(), \"\" | \"/\")\n}","tryCatchPattern":"match configure_base_url(input) {\n    Err(e) if e.to_string().contains(\"must include a host\") => { /* re-prompt for full origin */ }\n    other => other?,\n}","preventionTips":["Always store a complete origin like https://api.example.com","Reject empty or truncated URLs at config load","Prefer HTTPS; allow HTTP only for loopback testing"],"tags":["url","config-validation","invalid-url"],"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"}