nautechsystems/nautilus_trader · error
Missing block number
Error message
Missing block number
What it means
transform_hypersync_block converts a hypersync_client Block into the domain Block. The error fires when the source block's number field is None — a block without a number cannot be mapped into the domain model, which keys blocks by height.
Source
Thrown at crates/adapters/blockchain/src/hypersync/transform.rs:33
use alloy::primitives::U256;
use hypersync_client::format::Hex;
use nautilus_core::{UnixNanos, datetime::NANOSECONDS_IN_SECOND};
use nautilus_model::defi::{Block, Blockchain, hex::from_str_hex_to_u64};
use ustr::Ustr;
/// Converts a HyperSync block format to our internal [`Block`] type.
///
/// # Errors
///
/// Returns an error if required block fields are missing or if hex parsing fails.
pub fn transform_hypersync_block(
chain: Blockchain,
received_block: hypersync_client::simple_types::Block,
) -> Result<Block, anyhow::Error> {
let number = received_block
.number
.ok_or_else(|| anyhow::anyhow!("Missing block number"))?;
let gas_limit = from_str_hex_to_u64(
received_block
.gas_limit
.ok_or_else(|| anyhow::anyhow!("Missing gas limit"))?
.encode_hex()
.as_str(),
)?;
let gas_used = from_str_hex_to_u64(
received_block
.gas_used
.ok_or_else(|| anyhow::anyhow!("Missing gas used"))?
.encode_hex()
.as_str(),
)?;
let timestamp = from_str_hex_to_u64(
received_block
.timestamp
.ok_or_else(|| anyhow::anyhow!("Missing timestamp"))?View on GitHub (pinned to 18893faf8b)
Solutions
- Verify the HyperSync request selects the block number field
- Skip blocks with number == None and re-fetch them
- Check/update hypersync-client version for schema regressions
- Log the raw response to diagnose upstream data gaps
Example fix
// before
let number = received_block.number.ok_or_else(|| anyhow::anyhow!("Missing block number"))?;
// after
let Some(number) = received_block.number else {
tracing::warn!("hypersync block missing number; skipping block");
return Ok(None);
}; Defensive patterns
Strategy: validation
Validate before calling
if received_block.number.is_none() {
tracing::warn!("skipping hypersync block without number");
return Ok(None);
} Type guard
fn block_has_number(b: &hypersync_client::simple_types::Block) -> bool {
b.number.is_some()
} Try / catch
match transform_hypersync_block(chain, block) {
Ok(b) => /* use b */,
Err(e) => { tracing::warn!("block transform failed: {e}"); continue; }
} Prevention
- Include the block number in HyperSync block field selection
- Treat Option fields as required at the transform boundary and skip incomplete blocks
- Keep hypersync-client versions pinned and tested
When it happens
Trigger: pool_events_from_response receives a HyperSync response whose block object has number == None and passes it to transform_hypersync_block.
Common situations: Partial or malformed HyperSync responses; upstream API/schema changes; synthetic test blocks lacking a number; version mismatch between hypersync-client and expected schema.
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 gas limit
- Missing transaction hash in log
- Missing transaction index in the log
- Missing log index in the log
- Missing block number in the log
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/e99be5f58e94aed8.
Report an issue: GitHub.