{"record":{"id":"bbd15e40212581fc","repo":"nautechsystems/nautilus_trader","slug":"missing-log-index-in-the-log","errorCode":null,"errorMessage":"Missing log index in the log","messagePattern":"Missing log index in the log","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/hypersync/log.rs","lineNumber":73,"sourceCode":"///\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///\n/// Returns an error if the block number is not present in the log.\npub fn extract_block_number(log: &HypersyncLog) -> anyhow::Result<u64> {\n    log.block_number\n        .as_ref()\n        .map(|number| **number)\n        .ok_or_else(|| anyhow::anyhow!(\"Missing block number in the log\"))\n}\n\n/// Extracts the event signature from a log entry and returns it as a hex string\n///\n/// # Errors\n///","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/log.rs#L55-L91","documentation":"extract_log_index reads a Hypersync log's optional log_index and converts it to u32. The error fires when the log_index field is None; without it the event's position within the block's logs is unknown.","triggerScenarios":"Calling extract_log_index with a HypersyncLog whose log_index is None, typically from incomplete HyperSync log payloads.","commonSituations":"HyperSync queries not selecting log_index in the field selection; partial responses from the API; fixtures/tests constructing minimal logs.","solutions":["Include log_index in the HyperSync query field selection","Skip or re-fetch logs that lack log_index","Verify the hypersync-client version populates log_index correctly"],"exampleFix":"// before\nlet log_idx = extract_log_index(&log)?;\n// after\nif log.log_index.is_none() {\n    tracing::warn!(\"log missing log_index; skipping\");\n    return Ok(None);\n}\nlet log_idx = extract_log_index(&log)?;","handlingStrategy":"validation","validationCode":"fn has_log_index(log: &HypersyncLog) -> bool {\n    log.log_index.is_some()\n}\n// only call extract_log_index when this returns true","typeGuard":"fn log_has_log_index(log: &HypersyncLog) -> bool {\n    log.log_index.is_some()\n}","tryCatchPattern":"let log_idx = match extract_log_index(&log) {\n    Ok(i) => i,\n    Err(e) => { tracing::warn!(\"log lacks log_index: {e}\"); return Ok(None); }\n};","preventionTips":["Always select log_index in HyperSync field masks","Drop or re-fetch logs missing any required index field","Add a schema-conformance test for HyperSync log payloads"],"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-14T00:17:10.932Z"}