{"record":{"id":"0b04c024dba09aa9","repo":"FuelLabs/fuel-core","slug":"unable-to-decode-bytes","errorCode":null,"errorMessage":"Unable to decode bytes","messagePattern":"Unable to decode bytes","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/graphql_api/storage/transactions.rs","lineNumber":178,"sourceCode":"\n    fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {\n        let bytes: [u8; INDEX_SIZE] = bytes.try_into()?;\n        Ok(Self::from(bytes))\n    }\n}\n\nimpl Encode<OwnedTransactionIndexKey> for Manual<OwnedTransactionIndexKey> {\n    type Encoder<'a> = [u8; INDEX_SIZE];\n\n    fn encode(t: &OwnedTransactionIndexKey) -> Self::Encoder<'_> {\n        owned_tx_index_key(&t.owner, t.block_height, t.tx_idx)\n    }\n}\n\nimpl Decode<OwnedTransactionIndexKey> for Manual<OwnedTransactionIndexKey> {\n    fn decode(bytes: &[u8]) -> anyhow::Result<OwnedTransactionIndexKey> {\n        OwnedTransactionIndexKey::try_from(bytes)\n            .map_err(|_| anyhow::anyhow!(\"Unable to decode bytes\"))\n    }\n}\n\n#[derive(Clone, Debug, PartialOrd, Eq, PartialEq)]\npub struct OwnedTransactionIndexCursor {\n    pub block_height: BlockHeight,\n    pub tx_idx: TransactionIndex,\n}\n\nimpl From<OwnedTransactionIndexKey> for OwnedTransactionIndexCursor {\n    fn from(key: OwnedTransactionIndexKey) -> Self {\n        OwnedTransactionIndexCursor {\n            block_height: key.block_height,\n            tx_idx: key.tx_idx,\n        }\n    }\n}\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/graphql_api/storage/transactions.rs#L160-L196","documentation":"OwnedTransactionIndexKey is a fixed 38-byte record: 32-byte owner Address, 4-byte big-endian block height, 2-byte big-endian tx index. The Decode impl converts bytes via TryFrom<&[u8]>, which fails with TryFromSliceError when the slice length differs from INDEX_SIZE; that error is flattened into this opaque message.","triggerScenarios":"Decoding a key from the owned-transactions index whose byte length is not exactly 38 — corrupted keys, foreign data in the column, or a codec/format change between fuel-core versions.","commonSituations":"Reading an off-chain database written by an incompatible fuel-core version; partially written/corrupted storage after a crash; tooling that writes raw keys into the column with a different layout.","solutions":["Rebuild the off-chain database so the owned-transactions index is re-encoded by the current version.","Pin all nodes/tooling accessing the DB to one fuel-core version.","When writing custom tooling, use the OwnedTransactionIndexKey Encode impl rather than hand-built byte arrays."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const OWNED_TX_INDEX_SIZE: usize = 38; // 32 owner + 4 height + 2 tx idx\nif bytes.len() != OWNED_TX_INDEX_SIZE {\n    anyhow::bail!(\n        \"owned-transaction index key has {} bytes, expected {}\",\n        bytes.len(), OWNED_TX_INDEX_SIZE\n    );\n}","typeGuard":"fn is_owned_tx_index_key(bytes: &[u8]) -> bool {\n    bytes.len() == 38 // 32-byte owner + 4-byte height + 2-byte tx index\n}","tryCatchPattern":"match Manual::<OwnedTransactionIndexKey>::decode(&raw) {\n    Ok(k) => Ok(k),\n    Err(e) if e.to_string().contains(\"Unable to decode bytes\") => {\n        // length mismatch: corrupt or foreign key; rebuild the off-chain DB\n        anyhow::bail!(\"owned-tx index corrupt ({} bytes); rebuild off-chain DB\", raw.len())\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Keep every process touching the DB on one fuel-core version.","Use the provided Encode/Decode impls for index keys; never hand-pack bytes.","Rebuild the off-chain database after format-breaking upgrades."],"tags":["storage","codec","corruption","transactions","rust"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}