{"record":{"id":"9f406c50db7440f3","repo":"nautechsystems/nautilus_trader","slug":"collectprotocol-event-data-is-too-short","errorCode":null,"errorMessage":"CollectProtocol event data is too short","messagePattern":"CollectProtocol event data is too short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_collect.rs","lineNumber":72,"sourceCode":"pub fn parse_fee_protocol_collect_event_hypersync(\n    dex: SharedDex,\n    log: &HypersyncLog,\n) -> anyhow::Result<FeeProtocolCollectEvent> {\n    validate_event_signature_hash(\n        \"CollectProtocol\",\n        FEE_PROTOCOL_COLLECT_EVENT_SIGNATURE_HASH,\n        log,\n    )?;\n\n    let sender = extract_address_from_topic(log, 1, \"sender\")?;\n    let recipient = extract_address_from_topic(log, 2, \"recipient\")?;\n\n    if let Some(data) = &log.data {\n        let data_bytes = data.as_ref();\n\n        // Validate the data contains 2 parameters of 32 bytes each\n        if data_bytes.len() < 2 * 32 {\n            anyhow::bail!(\"CollectProtocol event data is too short\");\n        }\n\n        let decoded = match <FeeProtocolCollectEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode CollectProtocol event data: {e}\"),\n        };\n\n        let pool_address = Address::from_slice(\n            log.address\n                .clone()\n                .expect(\"Contract address should be set in logs\")\n                .as_ref(),\n        );\n        let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));\n\n        Ok(FeeProtocolCollectEvent::new(\n            dex,\n            pool_identifier,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_collect.rs#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"Provider glitches returning partial payloads; test logs constructed by concatenating fewer words; filtering mistakes pulling in non-CollectProtocol events.","solutions":["Check log.data length >= 64 before calling the parser","Confirm topic0 matches the CollectProtocol event signature","Re-fetch the log to rule out a truncated provider response","Skip and log such logs instead of failing the whole ingestion batch"],"exampleFix":"// before\nlet event = parse_fee_protocol_collect_event_hypersync(&dex, &log)?;\n// after\nlet ok = log.data.as_ref().map_or(true, |d| d.len() >= 2 * 32);\nanyhow::ensure!(ok, \"CollectProtocol data too short\");\nlet event = parse_fee_protocol_collect_event_hypersync(&dex, &log)?;","handlingStrategy":"validation","validationCode":"let ok = log.data.as_ref().map_or(true, |d| d.len() >= 2 * 32);\nif !ok {\n    tracing::warn!(\"CollectProtocol data too short, skipping log\");\n    return Ok(None);\n}","typeGuard":"fn collect_protocol_data_ok(log: &Log) -> bool {\n    log.data.as_deref().map_or(false, |d| d.len() >= 64)\n}","tryCatchPattern":"match parse_fee_protocol_collect_event_hypersync(&dex, &log) {\n    Ok(event) => handle(event),\n    Err(e) if e.to_string().contains(\"too short\") => {\n        tracing::warn!(\"short CollectProtocol data, re-fetching\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Filter by the exact CollectProtocol topic0 signature","Check data length >= 64 before decoding","Re-fetch rather than fail whole batches on truncated logs","Include short-data fixtures in unit tests"],"tags":["blockchain","uniswap-v3","fee-protocol","truncated-data"],"backgroundTag":"schema-validation-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}