nautechsystems/nautilus_trader · error
Missing log index in the log
Error message
Missing log index in the log
What it means
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.
Source
Thrown at crates/adapters/blockchain/src/hypersync/log.rs:73
///
/// Returns an error if the transaction index is not present in the log.
pub fn extract_transaction_index(log: &HypersyncLog) -> anyhow::Result<u32> {
log.transaction_index
.as_ref()
.map(|index| **index as u32)
.ok_or_else(|| anyhow::anyhow!("Missing transaction index in the log"))
}
/// Extracts the log index from a log entry
///
/// # Errors
///
/// 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
///View on GitHub (pinned to 18893faf8b)
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
Example fix
// before
let log_idx = extract_log_index(&log)?;
// after
if log.log_index.is_none() {
tracing::warn!("log missing log_index; skipping");
return Ok(None);
}
let log_idx = extract_log_index(&log)?; Defensive patterns
Strategy: validation
Validate before calling
fn has_log_index(log: &HypersyncLog) -> bool {
log.log_index.is_some()
}
// only call extract_log_index when this returns true Type guard
fn log_has_log_index(log: &HypersyncLog) -> bool {
log.log_index.is_some()
} Try / catch
let log_idx = match extract_log_index(&log) {
Ok(i) => i,
Err(e) => { tracing::warn!("log lacks log_index: {e}"); return Ok(None); }
}; Prevention
- 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
When it happens
Trigger: Calling extract_log_index with a HypersyncLog whose log_index is None, typically from incomplete HyperSync log payloads.
Common situations: HyperSync queries not selecting log_index in the field selection; partial responses from the API; fixtures/tests constructing minimal logs.
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
- Missing transaction hash in log
- Missing transaction index in the log
- Missing block number in the log
- Profiler log has no block hash
- Profiler watermark log has no event signature
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/bbd15e40212581fc.
Report an issue: GitHub.