{"record":{"id":"0ae66c1c30be4636","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-default-hyperliquid-http-client","errorCode":null,"errorMessage":"Failed to create default Hyperliquid HTTP client","messagePattern":"Failed to create default Hyperliquid HTTP client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/http/client.rs","lineNumber":949,"sourceCode":"    /// Mapping from symbol to asset index for order submission.\n    asset_indices: Arc<AtomicMap<Ustr, u32>>,\n    /// Mapping from spot fill coin (`@{pair_index}`) to instrument symbol.\n    spot_fill_coins: Arc<AtomicMap<Ustr, Ustr>>,\n    client_order_id_cloids: Arc<Mutex<AHashMap<ClientOrderId, Cloid>>>,\n    account_id: Option<AccountId>,\n    /// Optional override address for queries (agent wallet / API sub-key support).\n    /// When set, used for balance queries, position reports, and WS subscriptions\n    /// instead of the address derived from the private key.\n    account_address: Option<String>,\n    normalize_prices: bool,\n    market_order_slippage_bps: u32,\n    include_builder_attribution: bool,\n}\n\nimpl Default for HyperliquidHttpClient {\n    fn default() -> Self {\n        Self::new(HyperliquidEnvironment::Mainnet, 60, None)\n            .expect(\"Failed to create default Hyperliquid HTTP client\")\n    }\n}\n\nimpl HyperliquidHttpClient {\n    /// Creates a new [`HyperliquidHttpClient`] 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: HyperliquidEnvironment,\n        timeout_secs: u64,\n        proxy_url: Option<String>,\n    ) -> std::result::Result<Self, HttpClientError> {\n        let raw_client = HyperliquidRawHttpClient::new(environment, timeout_secs, proxy_url)?;\n        Ok(Self::from_raw(raw_client))\n    }\n","sourceCodeStart":931,"sourceCodeEnd":967,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/http/client.rs#L931-L967","documentation":"`HyperliquidHttpClient::default()` hardcodes Mainnet, a 60-second timeout, and no credentials, calling `Self::new(...)` and `expect`ing success. Since `new` performs environment/URL resolution and client construction that can fail (e.g. invalid environment URL, builder error), Default cannot propagate the error and instead panics. This only fires if the built-in default configuration is somehow invalid.","triggerScenarios":"Using `HyperliquidHttpClient::default()` (or a type that derefs/derives Default) when `HyperliquidHttpClient::new(Mainnet, 60, None)` fails — typically because the resolved Mainnet base URL is malformed or an internal client-builder step errors.","commonSituations":"Rare in practice; can surface if the environment constant/URL table is changed, in restricted environments where URL parsing or TLS setup fails, or in tests that alter environment configuration globally.","solutions":["Prefer calling `HyperliquidHttpClient::new(env, timeout, credentials)` directly and handle the Result, instead of relying on Default.","If Default must be used, verify the HyperliquidEnvironment::Mainnet URL configuration is intact.","Investigate the underlying error from `new` (URL parsing, TLS/backend init) by calling new explicitly to get the actual Err.","In test environments, construct the client with Testnet or an explicit URL via new."],"exampleFix":"// before\nlet client = HyperliquidHttpClient::default(); // panics on config error\n// after\nlet client = HyperliquidHttpClient::new(\n    HyperliquidEnvironment::Mainnet,\n    60,\n    None,\n)?;","handlingStrategy":"try-catch","validationCode":"// prefer explicit construction so the error is catchable:\nlet client = HyperliquidHttpClient::new(HyperliquidEnvironment::Mainnet, 60, None)\n    .map_err(|e| { eprintln!(\"client init failed: {e}\"); e })?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid Default for fallible clients; use new() and handle the Result","Keep environment URL tables intact when editing the adapter","In constrained/test environments construct with explicit env and URL"],"tags":["rust","panic","http-client","initialization","hyperliquid"],"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"}