{"record":{"id":"221e76c2b9db2407","repo":"nautechsystems/nautilus_trader","slug":"contract-address-should-be-set-in-logs-221e76","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/uniswap_v3/fee_protocol_collect.rs","lineNumber":83,"sourceCode":"    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,\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        ))\n    } else {\n        anyhow::bail!(\"Missing data in CollectProtocol event log\");","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_collect.rs#L65-L101","documentation":"parse_fee_protocol_collect_event_hypersync unwraps log.address with expect() because the CollectProtocol event's emitting address defines the pool identifier. Hypersync logs are expected to always carry an address; if absent, the parser panics, as documented in its # Panics section.","triggerScenarios":"Invoking parse_fee_protocol_collect_event_hypersync with a HypersyncLog missing address — from queries that did not select address, partial upstream rows, or fixtures without address, when the data decodes as a CollectProtocol event.","commonSituations":"Hypersync projection configuration errors; client library upgrades altering field optionality; manually constructed logs in tests like test_hypersync_rpc_match.","solutions":["Include address in the Hypersync query field selection.","Guard calls with a check that log.address.is_some() and skip otherwise.","Convert expect to ok_or + anyhow error for graceful failure."],"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 CollectProtocol log\"))?;\nlet pool_address = Address::from_slice(raw_address.as_ref());","handlingStrategy":"validation","validationCode":"if log.address.is_none() {\n    log::warn!(\"skipping CollectProtocol log without contract address\");\n    return Ok(());\n}\nlet event = parse_fee_protocol_collect_event_hypersync(dex.clone(), &log)?;","typeGuard":"fn has_address(log: &HypersyncLog) -> bool {\n    log.address.is_some()\n}","tryCatchPattern":"match parse_fee_protocol_collect_event_hypersync(dex, &log) {\n    Ok(event) => handle(event),\n    Err(e) => log::error!(\"failed to parse CollectProtocol log: {e:#}\"),\n}\n// Note: missing address panics via expect(); pre-check log.address before calling.","preventionTips":["Select the address column in Hypersync queries for fee protocol collect events.","Reject address-less logs at ingestion time with a warning.","Cover the missing-address case in tests so parser behavior is explicit."],"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-14T00:17:10.932Z"}