{"record":{"id":"9981cf58924b43a7","repo":"nautechsystems/nautilus_trader","slug":"e-9981cf","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/orderbook/own.rs","lineNumber":609,"sourceCode":"/// Filters orders by status and accepted timestamp.\n///\n/// `accepted_buffer_ns` acts as a grace period after `ts_accepted`. Orders whose\n/// `ts_accepted` is still zero (e.g. SUBMITTED/PENDING state before an ACCEPTED\n/// event) will pass the buffer check once `ts_now` exceeds the buffer, even though\n/// they have not been venue-acknowledged yet. Callers that want to hide inflight\n/// orders must additionally filter by `OrderStatus` (for example, include only\n/// `ACCEPTED` / `PARTIALLY_FILLED`).\n///\n/// # Panics\n///\n/// Panics if `accepted_buffer_ns` is positive and `ts_now` is `None`.\nfn filter_orders<'a>(\n    levels: impl Iterator<Item = &'a OwnBookLevel>,\n    status: Option<&AHashSet<OrderStatus>>,\n    accepted_buffer_ns: Option<u64>,\n    ts_now: Option<u64>,\n) -> IndexMap<Decimal, Vec<OwnBookOrder>> {\n    validate_accepted_buffer(accepted_buffer_ns, ts_now).unwrap_or_else(|e| panic!(\"{e}\"));\n    let accepted_buffer_ns = accepted_buffer_ns.unwrap_or(0);\n\n    levels\n        .map(|level| {\n            let orders = level\n                .orders\n                .values()\n                .filter(|order| status.is_none_or(|f| f.contains(&order.status)))\n                .filter(|order| {\n                    ts_now.is_none_or(|ts_now| {\n                        order\n                            .ts_accepted\n                            .checked_add(DurationNanos::new(accepted_buffer_ns))\n                            .is_some_and(|eligible_at| eligible_at.as_u64() <= ts_now)\n                    })\n                })\n                .copied()\n                .collect::<Vec<OwnBookOrder>>();","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/orderbook/own.rs#L591-L627","documentation":"In the own-order book, `filter_orders` validates the accepted-buffer/timestamp pair before filtering level orders; if `validate_accepted_buffer` returns an Err, the error message is re-panicked. This occurs when `accepted_buffer_ns` is provided without `ts_now` (or an inconsistent combination), so the buffer cannot be meaningfully applied.","triggerScenarios":"Calling `bids_as_map`/`asks_as_map` (which call `filter_orders`) passing `accepted_buffer_ns: Some(x)` while `ts_now: None`, or otherwise violating `validate_accepted_buffer`'s requirement that both are supplied together.","commonSituations":"Custom own-book snapshot code that sets a buffer for stale-order filtering but forgets to pass the current timestamp; refactored code where the ts_now argument was dropped.","solutions":["Either pass both `accepted_buffer_ns` and `ts_now`, or pass both as None.","If you only have a buffer, capture a current timestamp (e.g. from the book's ts_init or a clock) and pass it as ts_now.","Read `validate_accepted_buffer` to confirm the exact constraint and satisfy it in the caller.","If stale filtering is not needed, drop accepted_buffer_ns entirely."],"exampleFix":"// before\nbook.bids_as_map(Some(60_000_000_000), None); // panics: buffer without ts_now\n// after\nbook.bids_as_map(Some(60_000_000_000), Some(ts_now_ns));","handlingStrategy":"validation","validationCode":"// Before calling bids_as_map/asks_as_map:\nassert_eq!(\n    accepted_buffer_ns.is_some(),\n    ts_now.is_some(),\n    \"accepted_buffer_ns and ts_now must be supplied together\"\n);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass accepted_buffer_ns and ts_now as a pair, or both as None","Consult validate_accepted_buffer's contract before adding new callers","If you add a stale-order buffer, source a current timestamp from the clock at the same call site"],"tags":["rust","orderbook","panic","argument-validation"],"backgroundTag":"invalid-argument-value","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"}