{"record":{"id":"a10312a36522aa3a","repo":"nautechsystems/nautilus_trader","slug":"e-a10312","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":1730,"sourceCode":"                     AND identifier = ''\n                   ORDER BY ts_init ASC\"#,\n                )\n                .bind(type_name)\n                .bind(short_type)\n                .bind(&metadata_json)\n                .fetch_all(pool)\n                .await\n            }\n        }\n        .map_err(|e| anyhow::anyhow!(\"Failed to load custom data: {e}\"))?;\n\n        let mut results = Vec::with_capacity(rows.len());\n        for row in rows {\n            let value_json: serde_json::Value = row.try_get(\"value\")?;\n            let json_bytes = serde_json::to_vec(&value_json)\n                .map_err(|e| anyhow::anyhow!(\"Failed to serialize JSON: {e}\"))?;\n            let custom =\n                CustomData::from_json_bytes(&json_bytes).map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n            results.push(custom);\n        }\n        Ok(results)\n    }\n}\n","sourceCodeStart":1712,"sourceCodeEnd":1736,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/queries.rs#L1712-L1736","documentation":"Raised in `load_custom_data` when `CustomData::from_json_bytes` fails to deserialize a row's `value` JSON into a CustomData instance. The message is the inner error verbatim (`{e}`), typically a serde error about missing fields, wrong types, or an unknown data type name in the stored JSON.","triggerScenarios":"Calling `load_custom_data` where a stored `value` JSONB does not match the current CustomData schema — missing required fields after a model change, wrong data type requested, or rows written by a different library version.","commonSituations":"Schema evolution: stored payloads from an older version lack newly required fields; querying with the wrong data_type so rows deserialize into the wrong model; hand-edited rows in the database.","solutions":["Read the inner deserialization error to see which field/type failed.","Ensure the data_type filter matches how the rows were originally written.","Write a migration/backfill to transform old payload shapes to the current CustomData schema.","Pin compatible versions of the data model crate between writer and reader."],"exampleFix":"// before\nlet custom = CustomData::from_json_bytes(&json_bytes).map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n// after\nlet custom = match CustomData::from_json_bytes(&json_bytes) {\n    Ok(c) => c,\n    Err(e) => { tracing::warn!(\"skipping incompatible custom data row: {e}\"); continue; }\n};","handlingStrategy":"try-catch","validationCode":"// check the stored JSON has the fields CustomData requires\nlet v: serde_json::Value = row.try_get(\"value\")?;\nanyhow::ensure!(v.get(\"data_type\").is_some(), \"stored row missing data_type\");","typeGuard":"fn is_compatible_custom_data(v: &serde_json::Value) -> bool {\n    v.get(\"data_type\").and_then(|d| d.get(\"type_name\")).is_some()\n}","tryCatchPattern":"match CustomData::from_json_bytes(&json_bytes) {\n    Ok(c) => results.push(c),\n    Err(e) => {\n        tracing::warn!(\"skipping incompatible custom data row: {e}\");\n        // decide: skip vs fail-fast depending on workload\n    }\n}","preventionTips":["Use the same data model crate version for writers and readers","Run schema migrations when payload shape changes","Backfill/migrate old rows to the current schema","Verify data_type filters match how rows were written"],"tags":["serde","json","deserialization"],"backgroundTag":"json-unmarshal-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"}