nautechsystems/nautilus_trader · error

Missing block number in the log

Error message

Missing block number in the log

What it means

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.

Source

Thrown at crates/adapters/blockchain/src/hypersync/log.rs:85

///
/// Returns an error if the log index is not present in the log.
pub fn extract_log_index(log: &HypersyncLog) -> anyhow::Result<u32> {
    log.log_index
        .as_ref()
        .map(|index| **index as u32)
        .ok_or_else(|| anyhow::anyhow!("Missing log index in the log"))
}

/// Extracts the block number from a log entry
///
/// # Errors
///
/// Returns an error if the block number is not present in the log.
pub fn extract_block_number(log: &HypersyncLog) -> anyhow::Result<u64> {
    log.block_number
        .as_ref()
        .map(|number| **number)
        .ok_or_else(|| anyhow::anyhow!("Missing block number in the log"))
}

/// Extracts the event signature from a log entry and returns it as a hex string
///
/// # Errors
///
/// Returns an error if the event signature (topic0) is not present in the log.
pub fn extract_event_signature(log: &HypersyncLog) -> anyhow::Result<String> {
    extract_event_signature_bytes(log).map(hex::encode)
}

/// Extracts the event signature from a log entry and returns it as raw bytes
///
/// # Errors
///
/// Returns an error if the event signature (topic0) is not present in the log.
pub fn extract_event_signature_bytes(log: &HypersyncLog) -> anyhow::Result<&[u8]> {
    if let Some(topic) = log.topics.first().and_then(|t| t.as_ref()) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Include block_number in the HyperSync query field selection
  2. Re-fetch or skip the offending log entry
  3. Check hypersync-client/API version compatibility for the block_number field

Example fix

// before
let block_number = extract_block_number(&log)?;
// after
let Some(num) = log.block_number.as_ref().map(|n| **n) else {
    tracing::warn!("log missing block_number; skipping");
    return Ok(None);
};
Defensive patterns

Strategy: validation

Validate before calling

fn has_block_number(log: &HypersyncLog) -> bool {
    log.block_number.is_some()
}
// guard before extract_block_number

Type guard

fn log_has_block_number(log: &HypersyncLog) -> bool {
    log.block_number.is_some()
}

Try / catch

let block_number = match extract_block_number(&log) {
    Ok(n) => n,
    Err(e) => { tracing::warn!("log lacks block number: {e}"); return Ok(None); }
};

Prevention

When it happens

Trigger: Calling extract_block_number with a HypersyncLog whose block_number is None — an incomplete or malformed log from a HyperSync response.

Common situations: HyperSync queries that omit block_number from selected fields; partial API responses; schema changes in the upstream API dropping the field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/c3ec276ddbe91689. Report an issue: GitHub.