nautechsystems/nautilus_trader · error
Invalid receipt log data
Error message
Invalid receipt log data
What it means
During VerifiedReceiptLog construction, the log's data field string is parsed into alloy Bytes via Bytes::from_str. On failure the underlying error is discarded and replaced with 'Invalid receipt log data'. The data string must be 0x-prefixed hex with an even number of hex digits representing arbitrary bytes.
Source
Thrown at crates/adapters/blockchain/src/rpc/verification.rs:168
impl TryFrom<RpcTransactionReceipt> for VerifiedReceipt {
type Error = anyhow::Error;
fn try_from(receipt: RpcTransactionReceipt) -> Result<Self, Self::Error> {
let logs = receipt
.logs
.into_iter()
.map(|log| {
Ok(VerifiedReceiptLog {
removed: log.removed,
log_index: parse_optional_quantity(log.log_index.as_deref())?,
transaction_index: parse_optional_quantity(log.transaction_index.as_deref())?,
transaction_hash: parse_optional_hash(log.transaction_hash.as_deref())?,
block_hash: parse_optional_hash(log.block_hash.as_deref())?,
block_number: parse_optional_quantity(log.block_number.as_deref())?,
address: Address::from_str(&log.address)
.map_err(|_| anyhow::anyhow!("Invalid receipt log address"))?,
data: Bytes::from_str(&log.data)
.map_err(|_| anyhow::anyhow!("Invalid receipt log data"))?,
topics: log
.topics
.iter()
.map(|topic| {
B256::from_str(topic)
.map_err(|_| anyhow::anyhow!("Invalid receipt log topic"))
})
.collect::<anyhow::Result<_>>()?,
})
})
.collect::<anyhow::Result<_>>()?;
Ok(Self {
transaction_hash: receipt.transaction_hash,
block_hash: receipt.block_hash,
block_number: receipt.block_number,
gas_used: receipt.gas_used,
effective_gas_price: receipt.effective_gas_price,
transaction_index: receipt.transaction_index,View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the data string; ensure it is 0x-prefixed hex with an even digit count (0x alone is valid empty data for Bytes::from_str).
- Parse with Bytes::from_str ahead of receipt construction to surface the real decode error.
- If the source emits decimal/base64/non-hex data, convert it to hex before building the receipt.
- Correct or regenerate the fixture/ indexer output that produced the malformed data.
Example fix
// before "data": "0xabcdef0" // odd length // after "data": "0xabcdef00" // even-length hex bytes
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_bytes_hex(s: &str) -> bool {
let h = s.strip_prefix("0x").unwrap_or(s);
h.len() % 2 == 0 && h.chars().all(|c| c.is_ascii_hexdigit())
} Try / catch
let data = Bytes::from_str(&log.data)
.map_err(|e| anyhow::anyhow!("Invalid receipt log data '{}}}': {e}", log.data))?; Prevention
- Confirm the provider emits log data as 0x-prefixed, even-length hex.
- Convert decimal/base64 payloads to hex before constructing receipts.
- Pre-parse data fields when ingesting to fail fast with the real error.
- Keep fixtures generated from real receipts rather than hand-typed.
When it happens
Trigger: Verifying a receipt log whose data field is empty, missing the 0x prefix when required, contains non-hex characters, or has an odd number of hex digits so it cannot be converted into a byte vector.
Common situations: Upstream provider sending '0x' plus malformed payload or an odd-length hex string; fixtures with hand-typed data; a node returning data as a JSON array or base64 instead of hex; encoding changes after a provider/API version bump.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Invalid receipt log topic
- Invalid hex u64: {e}
- Invalid hex u32: {e}
- Invalid event signature for '{event_name}': expected {expect
- Failed to parse hex quantity '{s}': {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/0c25415c3324e322.
Report an issue: GitHub.