BoundaryML/baml · error

failed to create base http client: {}

Error message

failed to create base http client: {}

What it means

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.

Source

Thrown at engine/baml-runtime/src/internal/llm_client/primitive/aws/custom_http_client.rs:27

        },
        result::ConnectorError,
        runtime_components::RuntimeComponents,
    },
    http::Request,
};
use aws_smithy_types::body::SdkBody;
// --- WASM specific imports ---
#[cfg(target_arch = "wasm32")]
use {futures::channel::oneshot, wasm_bindgen_futures::spawn_local};

use crate::request::create_client;

/// Returns a wrapper around the global reqwest client.
/// [HttpClient].
#[cfg(not(target_arch = "wasm32"))] // Keep function non-WASM for now
pub fn client() -> anyhow::Result<Client> {
    let client = crate::request::create_client()
        .map_err(|e| anyhow::anyhow!("failed to create base http client: {}", e))?;
    Ok(Client::new(client.clone()))
}

#[cfg(target_arch = "wasm32")] // Define WASM client function
pub fn client() -> anyhow::Result<Client> {
    let client = crate::request::create_client()
        .map_err(|e| anyhow::anyhow!("failed to create base http client for WASM: {}", e))?;
    Ok(Client::new(client.clone()))
}

/// A wrapper around [reqwest::Client] that implements [HttpClient].
///
/// This is required to support using proxy servers with the AWS SDK.
#[derive(Debug, Clone)]
pub struct Client {
    inner: reqwest::Client,
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Fix or unset HTTP_PROXY / HTTPS_PROXY / ALL_PROXY environment variables so reqwest can parse them.
  2. Ensure the proxy URL uses http:// or https:// scheme and a valid host:port.
  3. Rebuild with reqwest TLS features enabled if using a custom BAML build.
  4. Check the wrapped inner error message for the exact reqwest failure cause.

Example fix

// before
export HTTPS_PROXY="proxy.corp.internal:8080" // missing scheme
// after
export HTTPS_PROXY="http://proxy.corp.internal:8080"
Defensive patterns

Strategy: try-catch

Validate before calling

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}`); }

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/8d67ea495593f7c3. Report an issue: GitHub.