nautechsystems/nautilus_trader · error

CollectProtocol event data is too short

Error message

CollectProtocol event data is too short

What it means

Raised by parse_fee_protocol_collect_event_hypersync when the CollectProtocol log's data is shorter than 64 bytes (2 x 32) needed for amount0 and amount1. The pre-check prevents the ABI decoder from failing on truncated payloads.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_collect.rs:72

pub fn parse_fee_protocol_collect_event_hypersync(
    dex: SharedDex,
    log: &HypersyncLog,
) -> anyhow::Result<FeeProtocolCollectEvent> {
    validate_event_signature_hash(
        "CollectProtocol",
        FEE_PROTOCOL_COLLECT_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 the data contains 2 parameters of 32 bytes each
        if data_bytes.len() < 2 * 32 {
            anyhow::bail!("CollectProtocol event data is too short");
        }

        let decoded = match <FeeProtocolCollectEventData as SolType>::abi_decode(data_bytes) {
            Ok(decoded) => decoded,
            Err(e) => anyhow::bail!("Failed to decode CollectProtocol 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(FeeProtocolCollectEvent::new(
            dex,
            pool_identifier,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check log.data length >= 64 before calling the parser
  2. Confirm topic0 matches the CollectProtocol event signature
  3. Re-fetch the log to rule out a truncated provider response
  4. Skip and log such logs instead of failing the whole ingestion batch

Example fix

// before
let event = parse_fee_protocol_collect_event_hypersync(&dex, &log)?;
// after
let ok = log.data.as_ref().map_or(true, |d| d.len() >= 2 * 32);
anyhow::ensure!(ok, "CollectProtocol data too short");
let event = parse_fee_protocol_collect_event_hypersync(&dex, &log)?;
Defensive patterns

Strategy: validation

Validate before calling

let ok = log.data.as_ref().map_or(true, |d| d.len() >= 2 * 32);
if !ok {
    tracing::warn!("CollectProtocol data too short, skipping log");
    return Ok(None);
}

Type guard

fn collect_protocol_data_ok(log: &Log) -> bool {
    log.data.as_deref().map_or(false, |d| d.len() >= 64)
}

Try / catch

match parse_fee_protocol_collect_event_hypersync(&dex, &log) {
    Ok(event) => handle(event),
    Err(e) if e.to_string().contains("too short") => {
        tracing::warn!("short CollectProtocol data, re-fetching");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: HyperSync returns a CollectProtocol log with truncated data; the log belongs to a different event with only one data word; hand-built fixture with short data.

Common situations: Provider glitches returning partial payloads; test logs constructed by concatenating fewer words; filtering mistakes pulling in non-CollectProtocol events.

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/9f406c50db7440f3. Report an issue: GitHub.