{"record":{"id":"07e92074343beb20","repo":"nautechsystems/nautilus_trader","slug":"failed-to-serialize-order-event-info-e","errorCode":null,"errorMessage":"Failed to serialize order event info: {e}","messagePattern":"Failed to serialize order event info: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":665,"sourceCode":"            \"#,\n            )\n            .bind(client_id.to_string())\n            .execute(&mut *transaction)\n            .await\n            .map(|_| ())\n            .map_err(|e| anyhow::anyhow!(\"Failed to insert into client table: {e}\"))?;\n        }\n\n        let exec_algorithm_params = order_event\n            .exec_algorithm_params()\n            .map(serde_json::to_value)\n            .transpose()\n            .map_err(|e| anyhow::anyhow!(\"Failed to serialize exec algorithm params: {e}\"))?;\n        let info = order_event\n            .info()\n            .map(serde_json::to_value)\n            .transpose()\n            .map_err(|e| anyhow::anyhow!(\"Failed to serialize order event info: {e}\"))?;\n\n        sqlx::query(r#\"\n            INSERT INTO \"order_event\" (\n                id, kind, client_order_id, order_type, order_side, trader_id, client_id, reason, strategy_id, instrument_id, trade_id, currency, quantity, time_in_force, liquidity_side,\n                post_only, reduce_only, quote_quantity, reconciliation, price, last_px, last_qty, trigger_price, trigger_type, limit_offset, trailing_offset,\n                trailing_offset_type, expire_time, display_qty, emulation_trigger, trigger_instrument_id, contingency_type,\n                order_list_id, linked_order_ids, parent_order_id,\n                exec_algorithm_id, exec_spawn_id, venue_order_id, account_id, position_id, commission, ts_event, ts_init, activation_price, exec_algorithm_params, tags,\n                released_price, protection_price, due_post_only, correction_id, is_reopened, info, causation_id, created_at, updated_at\n            ) VALUES (\n                $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20,\n                $21, $22, $23, $24, $25, $26::trailing_offset_type, $27, $28, $29, $30, $31, $32, $33, $34,\n                $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46,\n                $47, $48, $49, $50, $51, $52, $53, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP\n            )\n            ON CONFLICT (id)\n            DO UPDATE\n            SET","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/queries.rs#L647-L683","documentation":"Raised by `add_order_event` when `order_event.info()` is `Some` but its value cannot be serialized to JSON with `serde_json::to_value`. This happens before the order_event INSERT, so the database transaction is unaffected. It signals the event's info payload is not JSON-representable under serde_json's data model.","triggerScenarios":"Calling `add_order_event` on an order event whose `info()` returns data serde_json cannot serialize — e.g., non-string map keys, unsupported numeric types, or a failing custom `Serialize` impl.","commonSituations":"Vendor-specific order info structures with exotic field types; `serde_json` feature changes between versions; info maps keyed by integers or enums without string representation.","solutions":["Read the wrapped `serde_json::Error` in `{e}` to find the offending value.","Normalize `info()` payloads to JSON-compatible types (string map keys, standard numerics).","Fix the `Serialize` implementation for the info type.","Validate with `serde_json::to_value(event.info().unwrap())` in a unit test before persisting."],"exampleFix":"// before\ninfo: BTreeMap<InstrumentId, Quote>,\n// after\ninfo: BTreeMap<String, Quote>, // serde_json requires string keys","handlingStrategy":"validation","validationCode":"// Validate event info is JSON-serializable before persistence\nif let Some(info) = event.info() {\n    serde_json::to_value(info)\n        .map_err(|e| anyhow::anyhow!(\"event info not JSON-serializable: {e}\"))?;\n}","typeGuard":"fn is_json_serializable<T: serde::Serialize>(value: &T) -> bool {\n    serde_json::to_value(value).is_ok()\n}","tryCatchPattern":"match serde_json::to_value(event.info().unwrap()) {\n    Ok(v) => { /* proceed */ }\n    Err(e) => log::error!(\"info serialization failed: {e}\"),\n}","preventionTips":["Keep order info payloads to JSON-safe types (string keys, standard numerics).","Round-trip test vendor-specific info structs through serde_json.","Avoid hand-written Serialize impls; derive where possible."],"tags":["serialization","serde","json","rust"],"backgroundTag":"json-marshal-failed","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"}