nautechsystems/nautilus_trader · error

Missing log index

Error message

Missing log index

What it means

This error means the RpcLog's log_index field is None when extract_log_index is called. log_index is the position of the log entry within its block; it is absent for pending/unmined logs. Thrown before hex parsing.

Source

Thrown at crates/adapters/blockchain/src/rpc/log.rs:99

/// Returns an error if the transaction index is missing or cannot be parsed.
pub fn extract_transaction_index(log: &RpcLog) -> anyhow::Result<u32> {
    let hex = log
        .transaction_index
        .as_ref()
        .ok_or_else(|| anyhow::anyhow!("Missing transaction index"))?;
    parse_hex_u32(hex)
}

/// Extract log index from RPC log.
///
/// # Errors
///
/// Returns an error if the log index is missing or cannot be parsed.
pub fn extract_log_index(log: &RpcLog) -> anyhow::Result<u32> {
    let hex = log
        .log_index
        .as_ref()
        .ok_or_else(|| anyhow::anyhow!("Missing log index"))?;
    parse_hex_u32(hex)
}

/// Extract contract address from RPC log.
///
/// # Errors
///
/// Returns an error if the address is invalid.
pub fn extract_address(log: &RpcLog) -> anyhow::Result<Address> {
    let bytes = decode_hex(&log.address)?;
    anyhow::ensure!(
        bytes.len() == Address::len_bytes(),
        "Invalid contract address length: expected {} bytes, was {}",
        Address::len_bytes(),
        bytes.len()
    );
    Ok(Address::from_slice(&bytes))
}

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Only index logs from confirmed blocks.
  2. Skip or defer logs with no log_index.
  3. Confirm provider response includes logIndex and that deserialization matches its casing.
  4. Populate log_index in constructed test logs.

Example fix

// before
let idx = extract_log_index(&log)?;
// after
let idx = match extract_log_index(&log) {
    Ok(i) => i,
    Err(_) if log.log_index.is_none() => { defer(&log); return Ok(()); }
    Err(e) => return Err(e),
};
Defensive patterns

Strategy: validation

Validate before calling

if log.log_index.is_none() {
    // pending or unindexed log — defer
}

Type guard

fn has_log_index(log: &RpcLog) -> bool { log.log_index.is_some() }

Try / catch

let idx = match extract_log_index(&log) {
    Ok(i) => i,
    Err(_) if log.log_index.is_none() => { defer(&log); return Ok(()); }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: Calling extract_log_index on a pending log, a synthetic RpcLog, or deserialized JSON that omitted logIndex.

Common situations: Pending log subscriptions, providers that omit logIndex on pending receipts, or minimal test fixtures.

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/c8dd78b02a8ca3fb. Report an issue: GitHub.