{"record":{"id":"2335787fccd7cdc4","repo":"nautechsystems/nautilus_trader","slug":"missing-parent-hash","errorCode":null,"errorMessage":"Missing parent hash","messagePattern":"Missing parent hash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/hypersync/transform.rs","lineNumber":63,"sourceCode":"            .encode_hex()\n            .as_str(),\n    )?;\n    let timestamp = from_str_hex_to_u64(\n        received_block\n            .timestamp\n            .ok_or_else(|| anyhow::anyhow!(\"Missing timestamp\"))?\n            .encode_hex()\n            .as_str(),\n    )?;\n\n    let mut block = Block::new(\n        received_block\n            .hash\n            .ok_or_else(|| anyhow::anyhow!(\"Missing hash\"))?\n            .to_string(),\n        received_block\n            .parent_hash\n            .ok_or_else(|| anyhow::anyhow!(\"Missing parent hash\"))?\n            .to_string(),\n        number,\n        Ustr::from(\n            received_block\n                .miner\n                .ok_or_else(|| anyhow::anyhow!(\"Missing miner\"))?\n                .to_string()\n                .as_str(),\n        ),\n        gas_limit,\n        gas_used,\n        UnixNanos::new(timestamp * NANOSECONDS_IN_SECOND),\n        Some(chain),\n    );\n\n    if let Some(base_fee_hex) = received_block.base_fee_per_gas {\n        let s = base_fee_hex.encode_hex();\n        let val = U256::from_str_radix(s.trim_start_matches(\"0x\"), 16)?;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/transform.rs#L45-L81","documentation":"transform_hypersync_block requires parent_hash to link the new Block into the chain. The HyperSync block type carries parent_hash as optional; when absent the transform fails with this error instead of producing an orphaned Block with an empty parent reference.","triggerScenarios":"pool_events_from_response encountering a HyperSync block whose parent_hash is None — e.g. the query projection omitted parent_hash, or the genesis/pending block record lacks a parent reference.","commonSituations":"Processing the genesis block (which has no parent) through this transform; selective HyperSync queries excluding parent_hash; fixtures or cached responses missing the field.","solutions":["Include parent_hash in the HyperSync query field selection.","Skip or special-case the genesis block (hash of all zeros) before calling transform_hypersync_block.","If chain linkage is not needed, pass a zeroed parent hash (0x000...0) as a default.","Verify the block range is finalized so HyperSync returns complete parent references."],"exampleFix":"// before\nlet parent_hash = received_block.parent_hash.ok_or_else(|| anyhow::anyhow!(\"Missing parent hash\"))?.to_string();\n// after (genesis-safe default)\nlet parent_hash = received_block\n    .parent_hash\n    .map(|h| h.to_string())\n    .unwrap_or_else(|| \"0x0000000000000000000000000000000000000000000000000000000000000000\".to_string());","handlingStrategy":"validation","validationCode":"const ZERO_HASH: &str = \"0x0000000000000000000000000000000000000000000000000000000000000000\";\nfn is_genesis(b: &hypersync_client::simple_types::Block) -> bool {\n    b.parent_hash.is_none()\n        || b.parent_hash.as_ref().map(|h| h.to_string()).as_deref() == Some(ZERO_HASH)\n}\n// special-case genesis before transforming","typeGuard":"fn has_parent_hash(b: &hypersync_client::simple_types::Block) -> bool {\n    matches!(b.parent_hash, Some(_))\n}","tryCatchPattern":"match transform_hypersync_block(chain, block) {\n    Ok(b) => process(b),\n    Err(e) if e.to_string().contains(\"Missing parent hash\") => {\n        tracing::warn!(block = ?block.number, \"genesis or incomplete block; skipping\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Special-case block number 0 / genesis before the generic transform.","Keep parent_hash in the query field list.","Validate chain continuity by checking parent_hash matches the previous block's hash."],"tags":["blockchain","hypersync","missing-field","block-hash"],"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-14T05:17:10.506Z"}