{"record":{"id":"8d67ea495593f7c3","repo":"BoundaryML/baml","slug":"failed-to-create-base-http-client","errorCode":null,"errorMessage":"failed to create base http client: {}","messagePattern":"failed to create base http client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs","lineNumber":27,"sourceCode":"        },\n        result::ConnectorError,\n        runtime_components::RuntimeComponents,\n    },\n    http::Request,\n};\nuse aws_smithy_types::body::SdkBody;\n// --- WASM specific imports ---\n#[cfg(target_arch = \"wasm32\")]\nuse {futures::channel::oneshot, wasm_bindgen_futures::spawn_local};\n\nuse crate::request::create_client;\n\n/// Returns a wrapper around the global reqwest client.\n/// [HttpClient].\n#[cfg(not(target_arch = \"wasm32\"))] // Keep function non-WASM for now\npub fn client() -> anyhow::Result<Client> {\n    let client = crate::request::create_client()\n        .map_err(|e| anyhow::anyhow!(\"failed to create base http client: {}\", e))?;\n    Ok(Client::new(client.clone()))\n}\n\n#[cfg(target_arch = \"wasm32\")] // Define WASM client function\npub fn client() -> anyhow::Result<Client> {\n    let client = crate::request::create_client()\n        .map_err(|e| anyhow::anyhow!(\"failed to create base http client for WASM: {}\", e))?;\n    Ok(Client::new(client.clone()))\n}\n\n/// A wrapper around [reqwest::Client] that implements [HttpClient].\n///\n/// This is required to support using proxy servers with the AWS SDK.\n#[derive(Debug, Clone)]\npub struct Client {\n    inner: reqwest::Client,\n}\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs#L9-L45","documentation":"The AWS custom HTTP client wraps the global reqwest client; when crate::request::create_client() fails (e.g. invalid proxy configuration or TLS backend init failure), the error is re-wrapped with this message. The BAML client cannot be constructed without an underlying HTTP client.","triggerScenarios":"Constructing any AWS (Bedrock) BAML client on a non-WASM target while reqwest client creation fails — typically due to a malformed proxy URL in environment variables (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) or TLS init errors.","commonSituations":"Setting an invalid proxy env var (bad URL scheme, unparseable address) before running an app or test that initializes BAML Bedrock clients; corporate proxy misconfiguration; missing TLS features in a custom build.","solutions":["Fix or unset HTTP_PROXY / HTTPS_PROXY / ALL_PROXY environment variables so reqwest can parse them.","Ensure the proxy URL uses http:// or https:// scheme and a valid host:port.","Rebuild with reqwest TLS features enabled if using a custom BAML build.","Check the wrapped inner error message for the exact reqwest failure cause."],"exampleFix":"// before\nexport HTTPS_PROXY=\"proxy.corp.internal:8080\" // missing scheme\n// after\nexport HTTPS_PROXY=\"http://proxy.corp.internal:8080\"","handlingStrategy":"try-catch","validationCode":"for (const v of ['HTTP_PROXY','HTTPS_PROXY','ALL_PROXY','NO_PROXY']) { const p = process.env[v]; if (p && !/^https?:\\/\\//.test(p)) throw new Error(`Invalid ${v}: ${p}`); }","typeGuard":null,"tryCatchPattern":"try { const client = b.BamlRuntime...; } catch (e) { if (String(e).startsWith('failed to create base http client')) { console.error('Check proxy env vars / TLS setup:', e.cause ?? e.message); } throw e; }","preventionTips":["Validate proxy env vars are well-formed http(s) URLs before startup.","Avoid setting proxies in test/CI environments unless needed.","Build with reqwest TLS features enabled."],"tags":["http-client","reqwest","proxy","aws","init"],"backgroundTag":"module-init-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}