{"record":{"id":"cc4dd8049dc26886","repo":"nautechsystems/nautilus_trader","slug":"flash-event-data-is-too-short","errorCode":null,"errorMessage":"Flash event data is too short","messagePattern":"Flash event data is too short","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/flash.rs","lineNumber":70,"sourceCode":"///\n/// # Panics\n///\n/// Panics if the contract address is not set in the log.\npub fn parse_flash_event_hypersync(\n    dex: SharedDex,\n    log: &HypersyncLog,\n) -> anyhow::Result<FlashEvent> {\n    validate_event_signature_hash(\"FlashEvent\", FLASH_EVENT_SIGNATURE_HASH, log)?;\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 if data contains 4 parameters of 32 bytes each\n        if data_bytes.len() < 4 * 32 {\n            anyhow::bail!(\"Flash event data is too short\");\n        }\n\n        // Decode the data using the FlashEventData struct\n        let decoded = match <FlashEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode flash 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(FlashEvent::new(\n            dex,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/flash.rs#L52-L88","documentation":"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.","triggerScenarios":"A hypersync log matching the Flash topic arrives with data < 128 bytes — empty data field, truncated hex, or data belonging to a different event.","commonSituations":"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).","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."],"exampleFix":"// before\nif data_bytes.len() < 4 * 32 {\n    anyhow::bail!(\"Flash event data is too short\");\n}\n// after\nif data_bytes.len() != 4 * 32 {\n    anyhow::bail!(\"Flash event data must be exactly 128 bytes, got {}\", data_bytes.len());\n}","handlingStrategy":"validation","validationCode":"fn is_valid_flash_data(data: Option<&[u8]>) -> bool {\n    data.map(|d| d.len() == 4 * 32).unwrap_or(false)\n}","typeGuard":"fn has_flash_shape(log: &HypersyncLog) -> bool {\n    log.data.as_ref().map(|d| d.len() >= 128).unwrap_or(false)\n}","tryCatchPattern":"match parse_flash_event_hypersync(dex, &log) {\n    Ok(event) => handle(event),\n    Err(e) if e.to_string().contains(\"Flash event data\") => {\n        tracing::warn!(\"skipping malformed Flash log: {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["blockchain","uniswap-v3","hypersync","abi-decode"],"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"}