{"record":{"id":"d04537fc72bade17","repo":"Hmbown/CodeWhale","slug":"refusing-base-url-display-base-url-only-https","errorCode":null,"errorMessage":"Refusing base URL '{display_base_url}': only HTTPS (or explicitly allowed HTTP) URLs are supported.","messagePattern":"Refusing base URL '(.+?)': only HTTPS \\(or explicitly allowed HTTP\\) URLs are supported\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":1123,"sourceCode":"        logging::warn(format!(\n            \"Using insecure HTTP base URL because {ALLOW_INSECURE_HTTP_ENV} is set\"\n        ));\n        return Ok(());\n    }\n\n    if parsed.scheme() == \"http\" {\n        anyhow::bail!(\n            \"Refusing insecure base URL '{display_base_url}'.\\n\\\n             \\n\\\n             Loopback hosts (localhost, 127.0.0.1, [::1]) are auto-allowed.\\n\\\n             For one trusted local provider (LAN, llama.cpp on a private IP, etc.) set\\n\\\n             `allow_insecure_http = true` under its `[providers.<name>]` table in config.toml.\\n\\\n             To allow it for every provider in this shell instead, set the env var\\n\\\n             `{ALLOW_INSECURE_HTTP_ENV}=1` and re-run.\",\n        );\n    }\n\n    anyhow::bail!(\n        \"Refusing base URL '{display_base_url}': only HTTPS (or explicitly allowed HTTP) URLs are supported.\",\n    )\n}\n\n/// Mask credentials in a URL for display.\n///\n/// Delegates to the single shared implementation in\n/// [`codewhale_secrets::sanitize`] (FEAT-025 D4) so command sanitization and\n/// client diagnostics cannot drift.\npub(crate) fn redact_url_for_display(url: &str) -> String {\n    codewhale_secrets::sanitize::redact_url_for_display(url)\n}\n\npub(super) fn versioned_base_url(base_url: &str) -> String {\n    let trimmed = base_url.trim_end_matches('/');\n    if base_url_has_version_suffix(trimmed) {\n        trimmed.to_string()\n    } else {","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L1105-L1141","documentation":"This is a fail-closed security guard in the client's base-URL validation: it refuses any provider base_url whose scheme is not HTTPS. HTTP (plaintext) base URLs are only permitted when the user has explicitly opted in via `allow_insecure_http = true` in the provider's `[providers.<name>]` config table or via the ALLOW_INSECURE_HTTP_ENV environment variable, because plaintext HTTP exposes API keys and message contents on the wire.","triggerScenarios":"Configuring a `[providers.<name>]` base_url starting with `http://` (or scheme-less) in config.toml and starting a session; a provider preset/default pointing at a local plaintext endpoint (e.g. http://localhost:11434) without opting in.","commonSituations":"Pointing Codewhale at a local LLM server (Ollama, llama.cpp, LM Studio) using its http:// URL; copying an on-prem gateway URL that is plain HTTP; typos like `http://https://...`.","solutions":["Switch the provider base_url to an HTTPS endpoint (e.g. https://...).","If the endpoint is genuinely local or trusted HTTP, add `allow_insecure_http = true` under its `[providers.<name>]` table in config.toml.","Alternatively set the shell env var ALLOW_INSECURE_HTTP_ENV=1 to allow HTTP for every provider in this shell, then re-run.","If you meant HTTPS but typed http://, fix the scheme typo."],"exampleFix":"# before (config.toml)\n[providers.ollama]\nbase_url = \"http://localhost:11434\"\n\n# after\n[providers.ollama]\nbase_url = \"http://localhost:11434\"\nallow_insecure_http = true","handlingStrategy":"validation","validationCode":"fn ensure_https(base_url: &str, allow_http: bool) -> Result<(), String> {\n    let url = url::Url::parse(base_url).map_err(|e| format!(\"invalid base URL: {e}\"))?;\n    match url.scheme() {\n        \"https\" => Ok(()),\n        \"http\" if allow_http => Ok(()),\n        _ => Err(format!(\"base URL must be HTTPS (got '{}'); set allow_insecure_http to permit HTTP\", url.scheme())),\n    }\n}","typeGuard":"fn is_https(url: &str) -> bool {\n    url::Url::parse(url).map(|u| u.scheme() == \"https\").unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Always use HTTPS provider endpoints.","Set allow_insecure_http = true only for explicitly trusted local endpoints.","Lint config.toml for base_url scheme at load time."],"tags":["security","config","https","network"],"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"}