{"record":{"id":"31cb8157f85c4cc2","repo":"nautechsystems/nautilus_trader","slug":"durations-seconds-value-is-too-large-was-value","errorCode":null,"errorMessage":"`durations_seconds` value is too large, was {value}","messagePattern":"`durations_seconds` value is too large, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/time_range.rs","lineNumber":773,"sourceCode":"    let seconds = value.as_f64().with_context(|| {\n        format!(\"`durations_seconds` request parameter must contain numbers or null, was {value}\")\n    })?;\n\n    if !seconds.is_finite() || seconds < 0.0 {\n        anyhow::bail!(\n            \"`durations_seconds` request parameter must contain non-negative finite values, was {value}\"\n        );\n    }\n\n    let nanos = seconds * NANOSECONDS_IN_SECOND as f64;\n    if nanos < 1.0 {\n        anyhow::bail!(\n            \"`durations_seconds` request parameter must contain values of at least one nanosecond, was {value}\"\n        );\n    }\n\n    if nanos > u64::MAX as f64 {\n        anyhow::bail!(\"`durations_seconds` value is too large, was {value}\");\n    }\n\n    Ok(Some(DurationNanos::new(nanos as u64)))\n}\n\n#[cfg(test)]\nmod tests {\n    use nautilus_common::messages::data::{RequestCommand, RequestInstrument};\n    use nautilus_core::{Params, UUID4, UnixNanos};\n    use nautilus_model::identifiers::{ClientId, InstrumentId};\n    use rstest::rstest;\n    use serde_json::json;\n\n    use super::{\n        DefaultTimeRangeGenerator, TimeRangePipelineState, empty_time_range_parent_response,\n    };\n\n    #[rstest]","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/time_range.rs#L755-L791","documentation":"Converted nanoseconds are stored in a u64 (DurationNanos); values exceeding u64::MAX (~1.8e19 ns ≈ 584 years) would overflow and are rejected. This protects the generator from wrapping/overflowing window arithmetic.","triggerScenarios":"Passing an enormous durations_seconds value such as 1.0e20 seconds so nanos > u64::MAX as f64.","commonSituations":"Unit confusion (passing nanoseconds where seconds are expected); a formula producing absurdly large durations; careless use of very large sentinel values like f64::MAX.","solutions":["Use realistic duration values in seconds (e.g. 1.0, 60.0, 86400.0)","Check that the value is in seconds, not nanoseconds/milliseconds, before sending","Cap computed durations to a sane maximum before building the request"],"exampleFix":"// before\njson!([\"durations_seconds\" => [1.0e20]])\n// after\nlet seconds = 86400.0; // one day\nassert!(seconds * 1e9 <= u64::MAX as f64);","handlingStrategy":"validation","validationCode":"fn fits_u64_nanos(v: &serde_json::Value) -> bool {\n    matches!(v.as_f64(), Some(s) if s * 1e9 <= u64::MAX as f64)\n}","typeGuard":"let ok = values.iter().all(|v| v.is_null() || fits_u64_nanos(v));","tryCatchPattern":null,"preventionTips":["Confirm durations_seconds is in seconds, not ns/ms","Bound durations to realistic horizons before sending requests"],"tags":["rust","validation","overflow","duration"],"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"}