nautechsystems/nautilus_trader · error
`durations_seconds` value is too large, was {value}
Error message
`durations_seconds` value is too large, was {value} What it means
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.
Source
Thrown at crates/data/src/engine/time_range.rs:773
let seconds = value.as_f64().with_context(|| {
format!("`durations_seconds` request parameter must contain numbers or null, was {value}")
})?;
if !seconds.is_finite() || seconds < 0.0 {
anyhow::bail!(
"`durations_seconds` request parameter must contain non-negative finite values, was {value}"
);
}
let nanos = seconds * NANOSECONDS_IN_SECOND as f64;
if nanos < 1.0 {
anyhow::bail!(
"`durations_seconds` request parameter must contain values of at least one nanosecond, was {value}"
);
}
if nanos > u64::MAX as f64 {
anyhow::bail!("`durations_seconds` value is too large, was {value}");
}
Ok(Some(DurationNanos::new(nanos as u64)))
}
#[cfg(test)]
mod tests {
use nautilus_common::messages::data::{RequestCommand, RequestInstrument};
use nautilus_core::{Params, UUID4, UnixNanos};
use nautilus_model::identifiers::{ClientId, InstrumentId};
use rstest::rstest;
use serde_json::json;
use super::{
DefaultTimeRangeGenerator, TimeRangePipelineState, empty_time_range_parent_response,
};
#[rstest]View on GitHub (pinned to 18893faf8b)
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
Example fix
// before json!(["durations_seconds" => [1.0e20]]) // after let seconds = 86400.0; // one day assert!(seconds * 1e9 <= u64::MAX as f64);
Defensive patterns
Strategy: validation
Validate before calling
fn fits_u64_nanos(v: &serde_json::Value) -> bool {
matches!(v.as_f64(), Some(s) if s * 1e9 <= u64::MAX as f64)
} Type guard
let ok = values.iter().all(|v| v.is_null() || fits_u64_nanos(v));
Prevention
- Confirm durations_seconds is in seconds, not ns/ms
- Bound durations to realistic horizons before sending requests
When it happens
Trigger: Passing an enormous durations_seconds value such as 1.0e20 seconds so nanos > u64::MAX as f64.
Common situations: Unit confusion (passing nanoseconds where seconds are expected); a formula producing absurdly large durations; careless use of very large sentinel values like f64::MAX.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- {field} exceeds the maximum backoff duration
- DurationNanos overflow in from_micros
- {e}
- `durations_seconds` request parameter must contain non-negat
- `durations_seconds` request parameter must contain values of
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/31cb8157f85c4cc2.
Report an issue: GitHub.