{"record":{"id":"091425cfff8bc5ba","repo":"nautechsystems/nautilus_trader","slug":"missing-transaction-index-in-the-log","errorCode":null,"errorMessage":"Missing transaction index in the log","messagePattern":"Missing transaction index in the log","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/hypersync/log.rs","lineNumber":61,"sourceCode":"///\n/// Returns an error if the transaction hash is not present in the log.\npub fn extract_transaction_hash(log: &HypersyncLog) -> anyhow::Result<String> {\n    log.transaction_hash\n        .as_ref()\n        .map(ToString::to_string)\n        .ok_or_else(|| anyhow::anyhow!(\"Missing transaction hash in log\"))\n}\n\n/// Extracts the transaction index from a log entry\n///\n/// # Errors\n///\n/// Returns an error if the transaction index is not present in the log.\npub fn extract_transaction_index(log: &HypersyncLog) -> anyhow::Result<u32> {\n    log.transaction_index\n        .as_ref()\n        .map(|index| **index as u32)\n        .ok_or_else(|| anyhow::anyhow!(\"Missing transaction index in the log\"))\n}\n\n/// Extracts the log index from a log entry\n///\n/// # Errors\n///\n/// Returns an error if the log index is not present in the log.\npub fn extract_log_index(log: &HypersyncLog) -> anyhow::Result<u32> {\n    log.log_index\n        .as_ref()\n        .map(|index| **index as u32)\n        .ok_or_else(|| anyhow::anyhow!(\"Missing log index in the log\"))\n}\n\n/// Extracts the block number from a log entry\n///\n/// # Errors\n///","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/log.rs#L43-L79","documentation":"extract_transaction_index reads a Hypersync log's optional transaction_index and converts it to u32. The error fires when the field is absent, since ordering of events within a transaction cannot be determined without it.","triggerScenarios":"Calling extract_transaction_index with a HypersyncLog whose transaction_index is None (partial/underspecified log from a HyperSync response).","commonSituations":"HyperSync responses with missing index fields due to schema drift or partial decoding; custom log pipelines constructing logs without the index; tests using minimal log fixtures.","solutions":["Ensure the HyperSync query/request includes transaction_index in the selected fields","Skip or re-fetch logs lacking transaction_index","Update hypersync-client if a version regression drops the field"],"exampleFix":"// before\nlet idx = extract_transaction_index(&log)?;\n// after\nlet Some(idx) = log.transaction_index.as_ref().map(|i| **i as u32) else {\n    tracing::warn!(\"log missing transaction_index; skipping\");\n    return Ok(None);\n};","handlingStrategy":"validation","validationCode":"fn has_tx_index(log: &HypersyncLog) -> bool {\n    log.transaction_index.is_some()\n}\n// only call extract_transaction_index when this returns true","typeGuard":"fn log_has_tx_index(log: &HypersyncLog) -> bool {\n    log.transaction_index.is_some()\n}","tryCatchPattern":"let idx = match extract_transaction_index(&log) {\n    Ok(i) => i,\n    Err(e) => { tracing::warn!(\"log lacks tx index: {e}\"); return Ok(None); }\n};","preventionTips":["Include transaction_index in HyperSync query field selection","Check optional fields for None at ingestion time and skip incomplete records","Cover field presence in integration tests against real HyperSync data"],"tags":["hypersync","blockchain","logs","missing-field"],"backgroundTag":"missing-required-argument","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"}