{"record":{"id":"5f8e6e9d2c0bd7cf","repo":"nautechsystems/nautilus_trader","slug":"combined-bitmex-broadcaster-pool-size-overflow","errorCode":null,"errorMessage":"combined BitMEX broadcaster pool size overflow","messagePattern":"combined BitMEX broadcaster pool size overflow","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/config.rs","lineNumber":328,"sourceCode":"    #[must_use]\n    pub fn new() -> Self {\n        Self::default()\n    }\n\n    /// Validates the individual and combined broadcaster pool sizes.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if either pool is outside `[1, 15]` or their combined size is outside\n    /// `[2, 16]`.\n    pub(crate) fn validate_broadcaster_pool_sizes(&self) -> anyhow::Result<()> {\n        let submitter_pool_size = self.submitter_pool_size.unwrap_or(1);\n        let canceller_pool_size = self.canceller_pool_size.unwrap_or(1);\n        validate_broadcaster_pool_size(submitter_pool_size, \"submitter_pool_size\")?;\n        validate_broadcaster_pool_size(canceller_pool_size, \"canceller_pool_size\")?;\n        let combined_pool_size = submitter_pool_size\n            .checked_add(canceller_pool_size)\n            .ok_or_else(|| anyhow::anyhow!(\"combined BitMEX broadcaster pool size overflow\"))?;\n        check_in_range_inclusive_usize(\n            combined_pool_size,\n            2,\n            MAX_BROADCASTER_POOL_SIZE,\n            \"combined_pool_size\",\n        )?;\n        Ok(())\n    }\n\n    /// Returns `true` if both API key and secret are available\n    /// (either explicitly set or resolvable from environment variables).\n    #[must_use]\n    pub fn has_api_credentials(&self) -> bool {\n        let (key_var, secret_var) = credential_env_vars(self.environment);\n        let has_key = self.api_key.is_some() || std::env::var(key_var).is_ok();\n        let has_secret = self.api_secret.is_some() || std::env::var(secret_var).is_ok();\n        has_key && has_secret\n    }","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/config.rs#L310-L346","documentation":"Config validation in the BitMEX data client adds submitter_pool_size and canceller_pool_size (each defaulting to 1) and rejects the config when the checked_add overflows usize. This is a defensive guard; the range check to MAX_BROADCASTER_POOL_SIZE that follows normally catches oversized values first.","triggerScenarios":"Constructing the client (new -> validate_broadcaster_pool_sizes) with submitter_pool_size/canceller_pool_size whose sum exceeds usize::MAX — practically only via usize::MAX values in config.","commonSituations":"Programmatic config built with usize::MAX placeholders; config deserialization bugs injecting extreme values.","solutions":["Set submitter_pool_size and canceller_pool_size to small sane values (e.g. 1-16 each) so their sum stays within MAX_BROADCASTER_POOL_SIZE","Clamp or validate pool sizes at config load time before constructing the client"],"exampleFix":"// before\nsubmitter_pool_size: usize::MAX,\ncanceller_pool_size: usize::MAX,\n// after\nsubmitter_pool_size: 1,\ncanceller_pool_size: 1,","handlingStrategy":"validation","validationCode":"fn pool_sizes_ok(sub: usize, cancel: usize, max: usize) -> bool {\n    sub.checked_add(cancel).map_or(false, |t| (2..=max).contains(&t))\n}","typeGuard":null,"tryCatchPattern":"match BitmexDataClientConfig::new(...) {\n    Err(e) if e.to_string().contains(\"combined BitMEX broadcaster pool size overflow\") => {\n        eprintln!(\"pool sizes invalid, use small values (1-16): {e}\");\n    }\n    r => r?,\n}","preventionTips":["Keep submitter/canceller pool sizes at small values (their sum <= MAX_BROADCASTER_POOL_SIZE)","Clamp config values at deserialization time","Avoid usize::MAX sentinel placeholders in programmatic configs"],"tags":["config-validation","pool-size","overflow"],"backgroundTag":"value-out-of-range","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"}