nautechsystems/nautilus_trader · error
Failed to create default Coinbase HTTP client
Error message
Failed to create default Coinbase HTTP client
What it means
CoinbaseHttpClient::default() delegates to Self::new(CoinbaseEnvironment::Live, 10, None, None) and unwraps the Result with expect. If new() fails — for example building the HTTP reqwest client, the base URL, or internal rate-limit machinery — the Default impl panics with this message. It means the default client could not be constructed at all.
Source
Thrown at crates/adapters/coinbase/src/http/client.rs:802
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.adapters.coinbase", from_py_object)
)]
pub struct CoinbaseHttpClient {
pub(crate) inner: Arc<CoinbaseRawHttpClient>,
clock: &'static AtomicTime,
instruments: Arc<AtomicMap<InstrumentId, InstrumentAny>>,
/// Maps a product ID to its Coinbase-canonical alias (e.g. `BTC-USDC -> BTC-USD`).
/// Coinbase consolidates aliased pairs into a single book server-side, so the
/// WebSocket feed and user-channel echo the canonical id even when callers
/// subscribed or submitted with the alias.
product_aliases: Arc<AtomicMap<Ustr, Ustr>>,
}
impl Default for CoinbaseHttpClient {
fn default() -> Self {
Self::new(CoinbaseEnvironment::Live, 10, None, None)
.expect("Failed to create default Coinbase HTTP client")
}
}
impl CoinbaseHttpClient {
/// Creates a new [`CoinbaseHttpClient`] for public endpoints only.
///
/// # Errors
///
/// Returns an error if the HTTP client cannot be created.
pub fn new(
environment: CoinbaseEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
retry_config: Option<RetryConfig>,
) -> std::result::Result<Self, HttpClientError> {
let raw = CoinbaseRawHttpClient::new(environment, timeout_secs, proxy_url, retry_config)?;
Ok(Self::from_raw(raw))
}View on GitHub (pinned to 18893faf8b)
Solutions
- Replace reliance on default() with explicit CoinbaseHttpClient::new(...) and handle the Result with ?, anyhow context, or a graceful error path.
- Check that the reqwest/TLS features are correctly enabled for the target platform if the underlying build fails.
- Construct the client once at startup in main() where an error can be reported, not inside Default.
- Pin/verify crate versions so reqwest's client builder cannot fail on miscompiled TLS backends.
Example fix
// before
let client = CoinbaseHttpClient::default(); // panics on Err
// after
let client = CoinbaseHttpClient::new(CoinbaseEnvironment::Live, 10, None, None)
.context("Failed to create Coinbase HTTP client")?; Defensive patterns
Strategy: try-catch
Validate before calling
// Avoid default(); construct explicitly and handle the Result:
let client = match CoinbaseHttpClient::new(env, timeout, key, secret) {
Ok(c) => c,
Err(e) => { eprintln!("init failed: {e}"); return Err(e.into()); }
}; Try / catch
// Result-based handling (panics are not catchable idiomatically):
let client = CoinbaseHttpClient::new(CoinbaseEnvironment::Live, 10, None, None)
.map_err(|e| anyhow!("Coinbase client init failed: {e}"))?; Prevention
- Never rely on Default for clients with fallible construction; use new() with ?.
- Verify TLS/reqwest features for your target platform.
- Initialize clients once at startup where errors can be reported cleanly.
When it happens
Trigger: Using CoinbaseHttpClient::default() (directly or via Default trait in another struct) when CoinbaseHttpClient::new returns Err, e.g. reqwest client build failure due to TLS/backend init problems or an invalid environment/base-URL combination.
Common situations: Dependency or TLS backend misconfiguration at runtime; embedding the client in a struct deriving Default where fallible setup cannot be reported; environment misconfig where the Live base URL is rejected.
Related errors
- Latency model should be initialized
- Execution client should be initialized
- Failed to create HTTP client: {e}
- Failed to create default AxRawHttpClient
- Failed to create default AxHttpClient
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/98861b90fb35de4f.
Report an issue: GitHub.