{"record":{"id":"c3ec276ddbe91689","repo":"nautechsystems/nautilus_trader","slug":"missing-block-number-in-the-log","errorCode":null,"errorMessage":"Missing block number in the log","messagePattern":"Missing block number in the log","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/hypersync/log.rs","lineNumber":85,"sourceCode":"///\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///\n/// Returns an error if the event signature (topic0) is not present in the log.\npub fn extract_event_signature(log: &HypersyncLog) -> anyhow::Result<String> {\n    extract_event_signature_bytes(log).map(hex::encode)\n}\n\n/// Extracts the event signature from a log entry and returns it as raw bytes\n///\n/// # Errors\n///\n/// Returns an error if the event signature (topic0) is not present in the log.\npub fn extract_event_signature_bytes(log: &HypersyncLog) -> anyhow::Result<&[u8]> {\n    if let Some(topic) = log.topics.first().and_then(|t| t.as_ref()) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/log.rs#L67-L103","documentation":"extract_block_number reads a Hypersync log's optional block_number and returns it as u64. The error fires when the field is None, since block attribution of the log is required for ordering and state reconstruction.","triggerScenarios":"Calling extract_block_number with a HypersyncLog whose block_number is None — an incomplete or malformed log from a HyperSync response.","commonSituations":"HyperSync queries that omit block_number from selected fields; partial API responses; schema changes in the upstream API dropping the field.","solutions":["Include block_number in the HyperSync query field selection","Re-fetch or skip the offending log entry","Check hypersync-client/API version compatibility for the block_number field"],"exampleFix":"// before\nlet block_number = extract_block_number(&log)?;\n// after\nlet Some(num) = log.block_number.as_ref().map(|n| **n) else {\n    tracing::warn!(\"log missing block_number; skipping\");\n    return Ok(None);\n};","handlingStrategy":"validation","validationCode":"fn has_block_number(log: &HypersyncLog) -> bool {\n    log.block_number.is_some()\n}\n// guard before extract_block_number","typeGuard":"fn log_has_block_number(log: &HypersyncLog) -> bool {\n    log.block_number.is_some()\n}","tryCatchPattern":"let block_number = match extract_block_number(&log) {\n    Ok(n) => n,\n    Err(e) => { tracing::warn!(\"log lacks block number: {e}\"); return Ok(None); }\n};","preventionTips":["Request block_number in every HyperSync log query","Fail fast at ingestion boundaries when optional fields are None","Watch for upstream API/schema changes via contract tests"],"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"}