{"record":{"id":"26877210b10a7d44","repo":"FuelLabs/fuels-ts","slug":"decode-error-268772","errorCode":"DECODE_ERROR","errorMessage":"Invalid b512 data size.","messagePattern":"Invalid b512 data size\\.","errorType":"error_code","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/coders/B512Coder.ts","lineNumber":29,"sourceCode":"    super('b512', 'struct B512', WORD_SIZE * 8);\n  }\n\n  encode(value: string): Uint8Array {\n    let encodedValue;\n    try {\n      encodedValue = arrayify(value);\n    } catch (error) {\n      throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);\n    }\n    if (encodedValue.length !== this.encodedLength) {\n      throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);\n    }\n    return encodedValue;\n  }\n\n  decode(data: Uint8Array, offset: number): [string, number] {\n    if (data.length < this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b512 data size.`);\n    }\n\n    let bytes = data.slice(offset, offset + this.encodedLength);\n\n    const decoded = bn(bytes);\n    if (decoded.isZero()) {\n      bytes = new Uint8Array(64);\n    }\n\n    if (bytes.length !== this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid b512 byte data size.`);\n    }\n\n    return [toHex(bytes, this.encodedLength), offset + this.encodedLength];\n  }\n}\n","sourceCodeStart":11,"sourceCodeEnd":46,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/coders/B512Coder.ts#L11-L46","documentation":"Thrown by B512Coder.decode at the top guard: data.length < this.encodedLength (64). The message is the literal \"Invalid b512 data size.\". It means the byte buffer handed to decode cannot even contain one B512, so no slicing is attempted.","triggerScenarios":"Calling b512.decode(data, offset) where data is shorter than 64 bytes — e.g. decoding a receipt/log slice that was truncated, decoding at a bad offset, or feeding a raw partial payload. Note the guard checks total data.length, not offset-relative length.","commonSituations":"Manually decoding ABI-encoded log data whose leading bytes were stripped; using a wrong coder for the bytes on hand; chain/receipt data that was cut off in transit; offset bookkeeping that left fewer than 64 bytes available.","solutions":["Verify the source of the byte buffer and that it is the full, untouched encoded payload.","Ensure offset + 64 does not exceed data.length before calling decode.","Confirm you are using the correct coder (b512 vs b256) for this data.","Re-fetch the receipt/return value if it was truncated by the provider."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (data.length < 64) throw new Error(`need >= 64 bytes to decode b512, got ${data.length}`)\nb512.decode(data, offset)","typeGuard":"const canDecodeB512 = (data: Uint8Array) => data.length >= 64","tryCatchPattern":"try { b512.decode(data, offset) }\ncatch (e) { if ((e as FuelError).code === ErrorCode.DECODE_ERROR) { /* re-fetch or reject truncated payload */ } throw e }","preventionTips":["Do not hand-decode ABI data; prefer the high-level AbiCoder/Interface.","Treat short buffers as truncation and re-fetch from the provider.","Validate buffer length before manual decode."],"tags":["abi-coder","decoding","b512","data-length"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}