{"record":{"id":"a460331abd21a28c","repo":"nautechsystems/nautilus_trader","slug":"invalid-max-requests-per-second-max-requests-per-a46033","errorCode":null,"errorMessage":"Invalid max_requests_per_second: {max_requests_per_second} exceeds maximum","messagePattern":"Invalid max_requests_per_second: (.+?) exceeds maximum","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/http/spot/client.rs","lineNumber":279,"sourceCode":"    pub fn reset_cancellation_token(&self) {\n        *self.cancellation_token.write() = CancellationToken::new();\n    }\n\n    /// Returns a clone of the current cancellation token.\n    pub fn cancellation_token(&self) -> CancellationToken {\n        self.cancellation_token.read().clone()\n    }\n\n    fn default_headers() -> HashMap<String, String> {\n        HashMap::from([(USER_AGENT.to_string(), NAUTILUS_USER_AGENT.to_string())])\n    }\n\n    fn default_quota(max_requests_per_second: u32) -> anyhow::Result<Quota> {\n        let burst = NonZeroU32::new(max_requests_per_second).unwrap_or(\n            NonZeroU32::new(KRAKEN_SPOT_DEFAULT_RATE_LIMIT_PER_SECOND).expect(\"non-zero\"),\n        );\n        Quota::per_second(burst).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Invalid max_requests_per_second: {max_requests_per_second} exceeds maximum\"\n            )\n        })\n    }\n\n    fn rate_limiter_quotas(max_requests_per_second: u32) -> anyhow::Result<Vec<(String, Quota)>> {\n        Ok(vec![(\n            KRAKEN_GLOBAL_RATE_KEY.to_string(),\n            Self::default_quota(max_requests_per_second)?,\n        )])\n    }\n\n    fn rate_limit_keys(endpoint: &str) -> Vec<String> {\n        let normalized = endpoint.split('?').next().unwrap_or(endpoint);\n        let route = format!(\"kraken:spot:{normalized}\");\n        vec![KRAKEN_GLOBAL_RATE_KEY.to_string(), route]\n    }\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/http/spot/client.rs#L261-L297","documentation":"`default_quota` builds a per-second `governor::Quota` from the caller-supplied `max_requests_per_second`. `Quota::per_second` returns `None` when the burst exceeds the representable maximum, so the adapter converts that into this explicit anyhow error. It indicates the configured rate limit value is outside what the rate limiter supports.","triggerScenarios":"Calling the Kraken Spot client constructor (or `default_quota` directly) with `max_requests_per_second` so large that `Quota::per_second(NonZeroU32)` rejects it (exceeds governor's maximum burst, i.e. greater than u32::MAX / period constraints).","commonSituations":"Passing u32::MAX or a sentinel value like 0xFFFFFFFF as 'unlimited'; misconfigured adapter TOML with an absurd rate limit; copy-paste of a placeholder value.","solutions":["Lower `max_requests_per_second` to a realistic value (e.g. Kraken Spot public tier values like 1-20).","Use the default by passing 0: the code substitutes `KRAKEN_SPOT_DEFAULT_RATE_LIMIT_PER_SECOND` when the value is 0.","Check adapter config files/CLI overrides for an implausible rate-limit number."],"exampleFix":"// before\nmax_requests_per_second: u32::MAX,\n// after\nmax_requests_per_second: 10,","handlingStrategy":"validation","validationCode":"fn check_rps(max_requests_per_second: u32) -> Result<(), String> {\n    match max_requests_per_second {\n        0 => Ok(()), // defaults apply\n        1..=100 => Ok(()),\n        other => Err(format!(\"rate limit {} likely exceeds Quota::per_second maximum\", other)),\n    }\n}","typeGuard":null,"tryCatchPattern":"let quota = Self::default_quota(cfg.max_requests_per_second)\n    .map_err(|e| { log::error!(\"rate limit config invalid: {e}\"); e })?;","preventionTips":["Never use sentinel values like u32::MAX for 'unlimited' rate limits","Pass 0 to get the adapter default rate limit","Review adapter config files for implausible numeric values"],"tags":["rate-limit","quota","configuration","kraken"],"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-14T00:17:10.932Z"}