nautechsystems/nautilus_trader · error
Flash event data is too short
Error message
Flash event data is too short
What it means
Thrown by parse_flash_event_hypersync when the hypersync log's data is present but shorter than 4 x 32 = 128 bytes, the minimum for the Flash event's four parameters (amount0, amount1, paid0, paid1). The library validates length before attempting abi_decode.
Source
Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/flash.rs:70
///
/// # Panics
///
/// Panics if the contract address is not set in the log.
pub fn parse_flash_event_hypersync(
dex: SharedDex,
log: &HypersyncLog,
) -> anyhow::Result<FlashEvent> {
validate_event_signature_hash("FlashEvent", FLASH_EVENT_SIGNATURE_HASH, log)?;
let sender = extract_address_from_topic(log, 1, "sender")?;
let recipient = extract_address_from_topic(log, 2, "recipient")?;
if let Some(data) = &log.data {
let data_bytes = data.as_ref();
// Validate if data contains 4 parameters of 32 bytes each
if data_bytes.len() < 4 * 32 {
anyhow::bail!("Flash event data is too short");
}
// Decode the data using the FlashEventData struct
let decoded = match <FlashEventData as SolType>::abi_decode(data_bytes) {
Ok(decoded) => decoded,
Err(e) => anyhow::bail!("Failed to decode flash event data: {e}"),
};
let pool_address = Address::from_slice(
log.address
.clone()
.expect("Contract address should be set in logs")
.as_ref(),
);
let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));
Ok(FlashEvent::new(
dex,View on GitHub (pinned to 18893faf8b)
Solutions
- Filter the hypersync query on the exact Flash event topic0.
- Check log.data hex length >= 256 chars before parsing.
- Ensure the log originates from a standard Uniswap V3 pool (Flash events only exist there).
- Fix fixtures so data holds four 32-byte words.
- If a variant event with fewer fields is expected, adjust FlashEventData and the length check together.
Example fix
// before
if data_bytes.len() < 4 * 32 {
anyhow::bail!("Flash event data is too short");
}
// after
if data_bytes.len() != 4 * 32 {
anyhow::bail!("Flash event data must be exactly 128 bytes, got {}", data_bytes.len());
} Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_flash_data(data: Option<&[u8]>) -> bool {
data.map(|d| d.len() == 4 * 32).unwrap_or(false)
} Type guard
fn has_flash_shape(log: &HypersyncLog) -> bool {
log.data.as_ref().map(|d| d.len() >= 128).unwrap_or(false)
} Try / catch
match parse_flash_event_hypersync(dex, &log) {
Ok(event) => handle(event),
Err(e) if e.to_string().contains("Flash event data") => {
tracing::warn!("skipping malformed Flash log: {e}");
}
Err(e) => return Err(e),
} Prevention
- Filter hypersync queries by the exact Flash topic0
- Always select the data field in hypersync log queries
- Check data length == 128 bytes before parsing
- Restrict parsing to verified Uniswap V3 pool contracts
When it happens
Trigger: A hypersync log matching the Flash topic arrives with data < 128 bytes — empty data field, truncated hex, or data belonging to a different event.
Common situations: Hypersync queries not filtering on the Flash topic0; partial data returned by the provider; unit-test fixtures with short data (test_parse_flash_event_hypersync).
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- SetFeeProtocol event data is too short
- Failed to decode SetFeeProtocol event data: {e}
- Failed to decode flash event data: {e}
- Missing tickLower in topic2 when parsing burn event
- Missing data in SetFeeProtocol event log
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/cc4dd8049dc26886.
Report an issue: GitHub.