nautechsystems/nautilus_trader · error
Missing transaction index in the log
Error message
Missing transaction index in the log
What it means
extract_transaction_index reads a Hypersync log's optional transaction_index and converts it to u32. The error fires when the field is absent, since ordering of events within a transaction cannot be determined without it.
Source
Thrown at crates/adapters/blockchain/src/hypersync/log.rs:61
///
/// Returns an error if the transaction hash is not present in the log.
pub fn extract_transaction_hash(log: &HypersyncLog) -> anyhow::Result<String> {
log.transaction_hash
.as_ref()
.map(ToString::to_string)
.ok_or_else(|| anyhow::anyhow!("Missing transaction hash in log"))
}
/// Extracts the transaction index from a log entry
///
/// # Errors
///
/// 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
///View on GitHub (pinned to 18893faf8b)
Solutions
- Ensure the HyperSync query/request includes transaction_index in the selected fields
- Skip or re-fetch logs lacking transaction_index
- Update hypersync-client if a version regression drops the field
Example fix
// before
let idx = extract_transaction_index(&log)?;
// after
let Some(idx) = log.transaction_index.as_ref().map(|i| **i as u32) else {
tracing::warn!("log missing transaction_index; skipping");
return Ok(None);
}; Defensive patterns
Strategy: validation
Validate before calling
fn has_tx_index(log: &HypersyncLog) -> bool {
log.transaction_index.is_some()
}
// only call extract_transaction_index when this returns true Type guard
fn log_has_tx_index(log: &HypersyncLog) -> bool {
log.transaction_index.is_some()
} Try / catch
let idx = match extract_transaction_index(&log) {
Ok(i) => i,
Err(e) => { tracing::warn!("log lacks tx index: {e}"); return Ok(None); }
}; Prevention
- Include transaction_index in HyperSync query field selection
- Check optional fields for None at ingestion time and skip incomplete records
- Cover field presence in integration tests against real HyperSync data
When it happens
Trigger: Calling extract_transaction_index with a HypersyncLog whose transaction_index is None (partial/underspecified log from a HyperSync response).
Common situations: HyperSync responses with missing index fields due to schema drift or partial decoding; custom log pipelines constructing logs without the index; tests using minimal log 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
- Missing transaction hash in log
- Missing log 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/091425cfff8bc5ba.
Report an issue: GitHub.