{"record":{"id":"35056a15979509ed","repo":"nautechsystems/nautilus_trader","slug":"paircreated-event-data-too-short-expected-at-leas","errorCode":null,"errorMessage":"PairCreated event data too short: expected at least 32 bytes, was {}","messagePattern":"PairCreated event data too short: expected at least 32 bytes, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v2/pool_created.rs","lineNumber":54,"sourceCode":"/// - topic1: token0 (indexed)\n/// - topic2: token1 (indexed)\n/// - data: pair address (32 bytes) + pair count (32 bytes)\n///\n/// # Errors\n///\n/// Returns an error if the log parsing fails or if the event data is invalid.\npub fn parse_pool_created_event_hypersync(log: HypersyncLog) -> anyhow::Result<PoolCreatedEvent> {\n    validate_event_signature_hash(\"PairCreatedEvent\", PAIR_CREATED_EVENT_SIGNATURE_HASH, &log)?;\n\n    let block_number = extract_block_number(&log)?;\n    let token0 = extract_address_from_topic(&log, 1, \"token0\")?;\n    let token1 = extract_address_from_topic(&log, 2, \"token1\")?;\n\n    if let Some(data) = log.data {\n        // Data contains: [pair_address (32 bytes), pair_count (32 bytes)]\n        let data_bytes = data.as_ref();\n\n        anyhow::ensure!(\n            data_bytes.len() >= 32,\n            \"PairCreated event data too short: expected at least 32 bytes, was {}\",\n            data_bytes.len()\n        );\n\n        // Extract pair address (first 32 bytes, address is right-aligned)\n        let pair_address = Address::from_slice(&data_bytes[12..32]);\n        let pool_identifier = PoolIdentifier::Address(Ustr::from(&pair_address.to_string()));\n\n        Ok(PoolCreatedEvent::new(\n            block_number,\n            token0,\n            token1,\n            pair_address,\n            pool_identifier, // For V2/V3, pool_identifier = pool_address\n            None,            // V2 has no fee tiers (fixed 0.3%)\n            None,            // V2 has no tick spacing (CPAMM)\n        ))","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v2/pool_created.rs#L36-L72","documentation":"parse_pool_created_event_hypersync validates that the PairCreated event's data section contains at least 32 bytes — the right-aligned pair address word. It throws when the data payload is present but too short to contain the pair address, indicating a malformed or truncated log.","triggerScenarios":"Calling parse_pool_created_event_hypersync with a log whose data field is 1–31 bytes long, e.g. truncated record from hypersync or a non-standard factory contract emitting shorter data.","commonSituations":"Indexing an unofficial factory fork with a different PairCreated layout; corrupted/partial records from the data provider; decoding a similarly named but different event that slipped through signature checks.","solutions":["Verify log.data is a full 32+ byte payload (pair address word) before calling","Re-fetch the log; if persistent, the contract is non-standard — confirm the factory address and event ABI","Ensure the event signature check routed the log to the UniswapV2 PairCreated parser, not a fork's variant","Truncate gracefully: if data includes the extra uint256 word, ensure it is not cut mid-record"],"exampleFix":"// before\nlet data = log.data.as_ref().unwrap();\nlet pair = parse_pool_created_event_hypersync(&log)?;\n// after\nif log.data.as_ref().map_or(true, |d| d.len() < 32) { skip_record(); continue; }\nlet pair = parse_pool_created_event_hypersync(&log)?;","handlingStrategy":"validation","validationCode":"fn pair_data_ok(log: &Log) -> bool {\n    log.data.as_ref().map_or(false, |d| d.len() >= 32)\n}","typeGuard":null,"tryCatchPattern":"if !pair_data_ok(&log) { skip_malformed_record(&log); return Ok(()); }\nlet pool = parse_pool_created_event_hypersync(&log)?;","preventionTips":["Validate data length >= 32 bytes before parsing PairCreated events","Confirm the factory contract emits the standard UniswapV2 PairCreated layout","Re-fetch truncated records from the provider","Keep signature validation upstream so non-PairCreated events never reach this parser"],"tags":["ethereum","logs","uniswap-v2","validation"],"backgroundTag":"payload-too-large","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}