{"record":{"id":"2d075f71de969898","repo":"nautechsystems/nautilus_trader","slug":"invalid-trade-direction-other","errorCode":null,"errorMessage":"Invalid trade direction: {other}","messagePattern":"Invalid trade direction: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/common/parse.rs","lineNumber":800,"sourceCode":"// Parses a Deribit public trade into a Nautilus [`TradeTick`].\n///\n/// # Errors\n///\n/// Returns an error if:\n/// - The direction is not \"buy\" or \"sell\"\n/// - Decimal conversion fails for price or size\npub fn parse_trade_tick(\n    trade: &DeribitPublicTrade,\n    instrument_id: InstrumentId,\n    price_precision: u8,\n    size_precision: u8,\n    ts_init: UnixNanos,\n) -> anyhow::Result<TradeTick> {\n    // Parse aggressor side from direction\n    let aggressor_side = match trade.direction.as_str() {\n        \"buy\" => AggressorSide::Buy,\n        \"sell\" => AggressorSide::Sell,\n        other => anyhow::bail!(\"Invalid trade direction: {other}\"),\n    };\n    let price = Price::from_decimal_dp(trade.price, price_precision)?;\n    let size = Quantity::from_decimal_dp(trade.amount, size_precision)?;\n    let ts_event = UnixNanos::from((trade.timestamp as u64) * NANOSECONDS_IN_MILLISECOND);\n    let trade_id = build_public_trade_id(\n        &trade.trade_id,\n        trade.block_rfq_id,\n        trade.block_trade_id.as_deref(),\n        trade.combo_id.as_deref(),\n    );\n\n    Ok(TradeTick::new(\n        instrument_id,\n        price,\n        size,\n        aggressor_side,\n        trade_id,\n        ts_event,","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/common/parse.rs#L782-L818","documentation":"parse_trade_tick maps the Deribit public trade direction string to an aggressor side; only 'buy' and 'sell' are accepted, so any other string (or a changed API value) is rejected before price/size parsing proceeds.","triggerScenarios":"A Deribit trade tick whose direction field contains an unexpected value (e.g. changed casing, new enum value, or null serialized oddly).","commonSituations":"Deribit API adding a new direction variant, locale/case changes, corrupted payloads, custom test fixtures with invalid direction strings.","solutions":["Check the Deribit API docs for new direction values and update the match","Normalize direction casing before matching","Log and skip trades with unknown direction if resilience matters more than strictness"],"exampleFix":"// before\nother => anyhow::bail!(\"Invalid trade direction: {other}\"),\n// after\nother => {\n    log::warn!(\"Unknown trade direction '{other}', skipping trade\");\n    return Ok(None);\n}","handlingStrategy":"validation","validationCode":"assert!(matches!(trade.direction.as_str(), \"buy\" | \"sell\"), \"bad direction: {}\", trade.direction);","typeGuard":"fn known_direction(d: &str) -> bool { matches!(d, \"buy\" | \"sell\") }","tryCatchPattern":"match parse_trade_tick(&trade, ...).await /* or sync */ {\n    Err(e) if e.to_string().contains(\"Invalid trade direction\") => {\n        warn!(\"skipping trade with unknown direction\");\n    }\n    other => other?,\n}","preventionTips":["Normalize direction casing before parsing","Track Deribit API enum changes and update the parser","Skip-and-log unknown trade sides to preserve stream health"],"tags":["deribit","trade-tick","parsing","enum"],"backgroundTag":"invalid-enum-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"}