{"record":{"id":"447e8cd4ba3f594c","repo":"nautechsystems/nautilus_trader","slug":"initialize-event-data-is-too-short","errorCode":null,"errorMessage":"Initialize event data is too short","messagePattern":"Initialize event data is too short","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/initialize.rs","lineNumber":59,"sourceCode":"/// # Errors\n///\n/// Returns an error if the log parsing fails or if the event data is invalid.\n///\n/// # Panics\n///\n/// Panics if the contract address is not set in the log.\npub fn parse_initialize_event_hypersync(\n    dex: SharedDex,\n    log: &HypersyncLog,\n) -> anyhow::Result<InitializeEvent> {\n    validate_event_signature_hash(\"InitializeEvent\", INITIALIZE_EVENT_SIGNATURE_HASH, log)?;\n\n    if let Some(data) = &log.data {\n        let data_bytes = data.as_ref();\n\n        // Validate if data contains 2 parameters of 32 bytes each (sqrtPriceX96 and tick)\n        if data_bytes.len() < 2 * 32 {\n            anyhow::bail!(\"Initialize event data is too short\");\n        }\n\n        // Decode the data using the InitializeEventData struct\n        let decoded = match <InitializeEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode initialize 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(InitializeEvent::new(\n            dex,","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/initialize.rs#L41-L77","documentation":"Thrown by parse_initialize_event_hypersync when a Hypersync log's data payload is shorter than 64 bytes, i.e. it cannot contain the two 32-byte words (sqrtPriceX96, tick) required by the Uniswap V3 Initialize event. It is a fast-fail guard before attempting ABI decode, so no decode error detail is available — the data is simply too small.","triggerScenarios":"A Hypersync log matching the Initialize topic0 but carrying an empty or short data field, e.g. data is null/empty because the hypersync query did not request the data field, or a synthetic/malformed log in tests.","commonSituations":"Forgetting to select the log data column in a Hypersync query (data arrives None/empty), indexing a contract emitting a same-signature event with fewer parameters, or hand-built test logs missing data.","solutions":["Ensure the Hypersync query selects log data (include the data field in the log selection) before parsing.","Verify the log's topic0 matches the standard Uniswap V3 Initialize signature and originates from a V3 pool.","Log data_bytes.len() to confirm the payload size; it must be >= 64 bytes.","If building test fixtures, populate data with two 32-byte words (sqrtPriceX96 and tick)."],"exampleFix":"// before: query without data\nLogSelection { inner: vec![topic0], ..Default::default() }\n// after: request data\nLogSelection { inner: vec![topic0], field_selection: LogFieldSelection { data: vec![0], ..Default::default() } }","handlingStrategy":"validation","validationCode":"// Before calling parse_initialize_event_hypersync\nfn has_initialize_data(log: &HypersyncLog) -> bool {\n    log.data.as_ref().map(|d| d.as_ref().len() >= 64).unwrap_or(false)\n}\nif !has_initialize_data(&log) { continue; }","typeGuard":"fn has_data(log: &HypersyncLog) -> bool {\n    matches!(log.data, Some(ref d) if d.len() >= 2 * 32)\n}","tryCatchPattern":"match parse_initialize_event_hypersync(log, dex) {\n    Ok(event) => process(event),\n    Err(e) if e.to_string().contains(\"too short\") => {\n        log::debug!(\"log missing data (check hypersync field_selection): {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always request the log data field in the Hypersync field_selection","Check topic0 matches the canonical Initialize signature","Prefer strict length checks (== 64) over >= in your own pre-validation","Build test fixtures with complete two-word data payloads"],"tags":["abi-decode","uniswap-v3","hypersync","events"],"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-14T05:17:10.506Z"}