{"record":{"id":"897a2794b836358b","repo":"gleam-lang/gleam","slug":"unable-to-convert-http-request-for-use-by-reqwest","errorCode":null,"errorMessage":"Unable to convert HTTP request for use by reqwest library","messagePattern":"Unable to convert HTTP request for use by reqwest library","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/http.rs","lineNumber":43,"sourceCode":"        Self\n    }\n\n    pub fn boxed() -> Box<Self> {\n        Box::new(Self::new())\n    }\n}\n\n#[async_trait]\nimpl gleam_core::io::HttpClient for HttpClient {\n    async fn send(&self, request: Request<Vec<u8>>) -> Result<Response<Vec<u8>>> {\n        tracing::debug!(\n            method = request.method().as_str(),\n            url = request.uri().to_string(),\n            \"http-send\",\n        );\n        let request = request\n            .try_into()\n            .expect(\"Unable to convert HTTP request for use by reqwest library\");\n        let client = init_client().map_err(Error::http)?;\n        let mut response = client.execute(request).await.map_err(Error::http)?;\n        let mut builder = Response::builder()\n            .status(response.status())\n            .version(response.version());\n        if let Some(headers) = builder.headers_mut() {\n            std::mem::swap(headers, response.headers_mut());\n        }\n        builder\n            .body(response.bytes().await.map_err(Error::http)?.to_vec())\n            .map_err(Error::http)\n    }\n}\n\nfn init_client() -> Result<&'static Client, Error> {\n    if let Some(client) = REQWEST_CLIENT.get() {\n        return Ok(client);\n    }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/http.rs#L25-L61","documentation":"This panic occurs in the CLI's HTTP send helper when a gleam_core::http::Request cannot be converted into a native reqwest::Request via TryInto. The conversion is total for all well-formed requests the compiler builds, so a failure indicates an internal invariant violation (e.g. invalid URL or unsupported method/version combination reaching reqwest). The .expect() deliberately crashes rather than sending a malformed request.","triggerScenarios":"Any code path that calls send() — remove, revert, and authenticate commands, plus package downloads — when the request's URI or fields fail reqwest's request builder validation (e.g. a URL reqwest rejects, or a method/header that cannot be represented).","commonSituations":"An unreachable or malformed registry/base URL from a misconfigured package repository in gleam.toml or environment; a corrupted internal request construction after a gleam/gleam-core version mismatch; proxy environment variables producing URLs reqwest cannot parse.","solutions":["Check the package repository URL configured for the command (gleam.toml repositories / GLEAM_ env vars) is a well-formed absolute HTTP(S) URL","Update gleam to the latest version, as conversion failures usually indicate a compiler bug in request construction","Reproduce with RUST_BACKTRACE=1 and file a Gleam issue with the failing command and URL","Work around by fixing network config (HTTPS_PROXY etc.) if a proxy setting is mangling the URL"],"exampleFix":"// before (misconfigured repo URL)\n// gleam.toml: [dependencies] my_pkg = { path = \"../my_pkg\" } with repo URL \"myrepo\"\n// after\n// use a fully qualified URL the reqwest builder accepts:\n// repository = \"https://hex.pm/packages\"","handlingStrategy":"validation","validationCode":"fn assert_valid_request(req: &gleam_core::http::Request) -> Result<(), String> {\n    let url = req.uri().to_string();\n    if url.parse::<reqwest::Url>().is_err() {\n        return Err(format!(\"request URL not parseable: {}\", url));\n    }\n    Ok(())\n}","typeGuard":"fn is_http_url(s: &str) -> bool {\n    s.starts_with(\"http://\") || s.starts_with(\"https://\")\n}","tryCatchPattern":null,"preventionTips":["Keep repository/base URLs fully qualified with http(s) scheme","Avoid unusual proxy env vars that rewrite request URLs","Keep gleam updated; conversion failures are compiler bugs","Log method+URL before send to aid diagnosis"],"tags":["http","reqwest","panic","network"],"backgroundTag":"http-request-failed","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}