{"record":{"id":"98861b90fb35de4f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-default-coinbase-http-client","errorCode":null,"errorMessage":"Failed to create default Coinbase HTTP client","messagePattern":"Failed to create default Coinbase HTTP client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/http/client.rs","lineNumber":802,"sourceCode":"#[cfg_attr(\n    feature = \"python\",\n    pyo3::pyclass(module = \"nautilus_trader.adapters.coinbase\", from_py_object)\n)]\npub struct CoinbaseHttpClient {\n    pub(crate) inner: Arc<CoinbaseRawHttpClient>,\n    clock: &'static AtomicTime,\n    instruments: Arc<AtomicMap<InstrumentId, InstrumentAny>>,\n    /// Maps a product ID to its Coinbase-canonical alias (e.g. `BTC-USDC -> BTC-USD`).\n    /// Coinbase consolidates aliased pairs into a single book server-side, so the\n    /// WebSocket feed and user-channel echo the canonical id even when callers\n    /// subscribed or submitted with the alias.\n    product_aliases: Arc<AtomicMap<Ustr, Ustr>>,\n}\n\nimpl Default for CoinbaseHttpClient {\n    fn default() -> Self {\n        Self::new(CoinbaseEnvironment::Live, 10, None, None)\n            .expect(\"Failed to create default Coinbase HTTP client\")\n    }\n}\n\nimpl CoinbaseHttpClient {\n    /// Creates a new [`CoinbaseHttpClient`] for public endpoints only.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the HTTP client cannot be created.\n    pub fn new(\n        environment: CoinbaseEnvironment,\n        timeout_secs: u64,\n        proxy_url: Option<String>,\n        retry_config: Option<RetryConfig>,\n    ) -> std::result::Result<Self, HttpClientError> {\n        let raw = CoinbaseRawHttpClient::new(environment, timeout_secs, proxy_url, retry_config)?;\n        Ok(Self::from_raw(raw))\n    }","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/http/client.rs#L784-L820","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet client = CoinbaseHttpClient::default(); // panics on Err\n// after\nlet client = CoinbaseHttpClient::new(CoinbaseEnvironment::Live, 10, None, None)\n    .context(\"Failed to create Coinbase HTTP client\")?;","handlingStrategy":"try-catch","validationCode":"// Avoid default(); construct explicitly and handle the Result:\nlet client = match CoinbaseHttpClient::new(env, timeout, key, secret) {\n    Ok(c) => c,\n    Err(e) => { eprintln!(\"init failed: {e}\"); return Err(e.into()); }\n};","typeGuard":null,"tryCatchPattern":"// Result-based handling (panics are not catchable idiomatically):\nlet client = CoinbaseHttpClient::new(CoinbaseEnvironment::Live, 10, None, None)\n    .map_err(|e| anyhow!(\"Coinbase client init failed: {e}\"))?;","preventionTips":["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."],"tags":["rust","http","panic","coinbase","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}