{"record":{"id":"e2648f8aaa73e9ff","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-default-axhttpclient","errorCode":null,"errorMessage":"Failed to create default AxHttpClient","messagePattern":"Failed to create default AxHttpClient","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":1162,"sourceCode":"    account_fees: Arc<ArcSwapOption<(Decimal, Decimal)>>,\n}\n\nimpl Clone for AxHttpClient {\n    fn clone(&self) -> Self {\n        Self {\n            inner: self.inner.clone(),\n            instruments_cache: self.instruments_cache.clone(),\n            cache_initialized: self.cache_initialized.clone(),\n            clock: self.clock,\n            account_fees: self.account_fees.clone(),\n        }\n    }\n}\n\nimpl Default for AxHttpClient {\n    fn default() -> Self {\n        Self::new(None, None, 60, 3, 1000, 10_000, None)\n            .expect(\"Failed to create default AxHttpClient\")\n    }\n}\n\nimpl AxHttpClient {\n    /// Creates a new [`AxHttpClient`] using the default Ax HTTP URL.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the retry manager cannot be created.\n    pub fn new(\n        base_url: Option<String>,\n        orders_base_url: Option<String>,\n        timeout_secs: u64,\n        max_retries: u32,\n        retry_delay_ms: u64,\n        retry_delay_max_ms: u64,\n        proxy_url: Option<String>,\n    ) -> Result<Self, AxHttpError> {","sourceCodeStart":1144,"sourceCodeEnd":1180,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L1144-L1180","documentation":"AxHttpClient::default() calls new(None, None, 60, 3, 1000, 10_000, None) and expects success, panicking with 'Failed to create default AxHttpClient' if the underlying construction — default URL parsing and reqwest client building (which also constructs the raw client internally) — returns Err.","triggerScenarios":"Calling AxHttpClient::default() when the built-in default AX HTTP URL fails to parse, or the internal reqwest/AxRawHttpClient construction fails (TLS/runtime initialization problems).","commonSituations":"Startup of the AX adapter in environments where reqwest's TLS backend cannot initialize; relying on Default in tests or binaries after an adapter version changed the default URL; miscompiled reqwest feature set.","solutions":["Use AxHttpClient::new(...) explicitly and handle its Result instead of Default's expect.","Supply an explicit base URL and credentials through new() to rule out default-constant issues.","Verify reqwest TLS features (rustls vs native-tls) and that the binary links them correctly.","Confirm the default URL constant is still valid after upgrading the adapter crate."],"exampleFix":"// before\nlet client = AxHttpClient::default(); // panics on failure\n// after\nlet client = AxHttpClient::new(None, None, 60, 3, 1000, 10_000, None)?; // propagate the error","handlingStrategy":"try-catch","validationCode":"// Ensure the default URL is parseable and TLS backend available before Default-based construction\nassert!(url::Url::parse(DEFAULT_AX_HTTP_URL).is_ok(), \"default AX URL invalid\");","typeGuard":null,"tryCatchPattern":"// Avoid Default()'s expect; construct explicitly and handle the error:\nlet client = AxHttpClient::new(None, None, 60, 3, 1000, 10_000, None)\n    .map_err(|e| anyhow!(\"AxHttpClient init failed: {e}\"))?;","preventionTips":["Use AxHttpClient::new with explicit arguments instead of Default in services.","Run a startup health check that constructs the client once before trading begins.","After adapter upgrades, re-verify the built-in default URL constant."],"tags":["http-client","panic","initialization","rust","architect-ax"],"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-14T00:17:10.932Z"}