{"record":{"id":"96327295528f101c","repo":"nautechsystems/nautilus_trader","slug":"contract-address-should-be-set-in-logs-963272","errorCode":null,"errorMessage":"Contract address should be set in logs","messagePattern":"Contract address should be set in logs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/pancakeswap_v3/swap.rs","lineNumber":81,"sourceCode":"\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        if data_bytes.len() < 7 * 32 {\n            anyhow::bail!(\"Swap event data is too short\");\n        }\n\n        let decoded = match <SwapEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode swap event data: {e}\"),\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        Ok(SwapEvent::new(\n            dex,\n            pool_identifier,\n            extract_block_number(log)?,\n            extract_transaction_hash(log)?,\n            extract_transaction_index(log)?,\n            extract_log_index(log)?,\n            sender,\n            recipient,\n            decoded.amount0,\n            decoded.amount1,\n            decoded.sqrt_price_x96,\n            decoded.liquidity,\n            decoded.tick.as_i32(),\n        ))","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/pancakeswap_v3/swap.rs#L63-L99","documentation":"parse_swap_event_hypersync requires log.address to be present: it is the pool contract address converted into a PoolIdentifier for the SwapEvent. The parser asserts this with expect(), documented as a panic condition, because a Swap log without an emitting address is considered malformed input that the caller should have filtered.","triggerScenarios":"Calling parse_swap_event_hypersync with a HypersyncLog where address is None — Hypersync result rows lacking the address field, or test fixtures constructing logs without address, when topic/data otherwise match the Swap signature.","commonSituations":"Hypersync queries with projections excluding address; version drift in the Hypersync client/arrow schema dropping the field; handcrafted log fixtures in integration tests.","solutions":["Include the address field in the Hypersync log query so all rows carry the emitting contract address.","Filter logs with address None upstream (e.g. validate_event_signature_hash-style guard or a pre-check) before parsing.","Convert the expect into an anyhow error return inside the parser for graceful handling."],"exampleFix":"// before\nlet pool_address = Address::from_slice(\n    log.address.clone().expect(\"Contract address should be set in logs\").as_ref(),\n);\n// after\nlet raw_address = log.address.as_ref()\n    .ok_or_else(|| anyhow::anyhow!(\"missing contract address in swap log\"))?;\nlet pool_address = Address::from_slice(raw_address.as_ref());","handlingStrategy":"validation","validationCode":"if log.address.is_none() {\n    log::warn!(\"skipping swap log without contract address\");\n    return Ok(());\n}\nlet event = parse_swap_event_hypersync(dex.clone(), &log)?;","typeGuard":"fn has_address(log: &HypersyncLog) -> bool {\n    log.address.is_some()\n}","tryCatchPattern":"match parse_swap_event_hypersync(dex, &log) {\n    Ok(event) => handle(event),\n    Err(e) => log::error!(\"failed to parse swap log: {e:#}\"),\n}\n// Note: missing address panics via expect(); pre-check log.address before calling.","preventionTips":["Select the address field in every Hypersync query used for swap ingestion.","Filter address-less logs once, centrally, before dispatching to event parsers.","Keep test fixtures for HypersyncLog complete (set address) so tests reflect real rows."],"tags":["panic","missing-field","hypersync","blockchain-logs","rust"],"backgroundTag":"null-argument","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"}