{"record":{"id":"7942b6739ba85d08","repo":"nautechsystems/nautilus_trader","slug":"missing-transaction-index","errorCode":null,"errorMessage":"Missing transaction index","messagePattern":"Missing transaction index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/log.rs","lineNumber":86,"sourceCode":"/// # Errors\n///\n/// Returns an error if the transaction hash is missing.\npub fn extract_transaction_hash(log: &RpcLog) -> anyhow::Result<String> {\n    log.transaction_hash\n        .clone()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing transaction hash\"))\n}\n\n/// Extract transaction index from RPC log.\n///\n/// # Errors\n///\n/// Returns an error if the transaction index is missing or cannot be parsed.\npub fn extract_transaction_index(log: &RpcLog) -> anyhow::Result<u32> {\n    let hex = log\n        .transaction_index\n        .as_ref()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing transaction index\"))?;\n    parse_hex_u32(hex)\n}\n\n/// Extract log index from RPC log.\n///\n/// # Errors\n///\n/// Returns an error if the log index is missing or cannot be parsed.\npub fn extract_log_index(log: &RpcLog) -> anyhow::Result<u32> {\n    let hex = log\n        .log_index\n        .as_ref()\n        .ok_or_else(|| anyhow::anyhow!(\"Missing log index\"))?;\n    parse_hex_u32(hex)\n}\n\n/// Extract contract address from RPC log.\n///","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/log.rs#L68-L104","documentation":"This error means the RpcLog's transaction_index field is None when extract_transaction_index is called. Transaction index is the position of the transaction within its block; it is absent on pending transactions before mining. Thrown before hex parsing.","triggerScenarios":"Calling extract_transaction_index on a log from a pending receipt, on a manually constructed RpcLog, or on deserialized JSON missing transactionIndex.","commonSituations":"Pending log streams, nonstandard providers omitting index fields, or incomplete test fixtures.","solutions":["Process logs only after the transaction is mined/confirmed.","Handle None explicitly: skip or defer the log.","Verify the RPC response includes transactionIndex (check provider docs and serde field naming).","Set transaction_index (e.g. \"0x0\") in hand-built logs for tests."],"exampleFix":"// before\nlet idx = extract_transaction_index(&log)?;\n// after\nlet Some(_) = log.transaction_index else { skip_pending_log(); return Ok(()) };\nlet idx = extract_transaction_index(&log)?;","handlingStrategy":"validation","validationCode":"if log.transaction_index.is_none() {\n    // pending log — defer until mined\n}","typeGuard":"fn has_tx_index(log: &RpcLog) -> bool { log.transaction_index.is_some() }","tryCatchPattern":"let idx = match extract_transaction_index(&log) {\n    Ok(i) => i,\n    Err(_) if log.transaction_index.is_none() => { defer(&log); return Ok(()); }\n    Err(e) => return Err(e),\n};","preventionTips":["Wait for transaction confirmation before parsing.","Verify transactionIndex is present in provider responses.","Skip pending logs instead of erroring.","Set transaction_index in test logs."],"tags":["blockchain","rpc","missing-field","ethereum"],"backgroundTag":"missing-required-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"}