{"record":{"id":"882c02c9e9328859","repo":"FuelLabs/fuels-ts","slug":"decode-error-882c02","errorCode":"DECODE_ERROR","errorMessage":"Invalid tuple data size.","messagePattern":"Invalid tuple data size\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/coders/TupleCoder.ts","lineNumber":40,"sourceCode":"\n  constructor(coders: TCoders) {\n    const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0);\n    super('tuple', `(${coders.map((coder) => coder.type).join(', ')})`, encodedLength);\n    this.coders = coders;\n    this.#hasNestedOption = hasNestedOption(coders);\n  }\n\n  encode(value: InputValueOf<TCoders>): Uint8Array {\n    if (this.coders.length !== value.length) {\n      throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`);\n    }\n\n    return concatBytes(this.coders.map((coder, i) => coder.encode(value[i])));\n  }\n\n  decode(data: Uint8Array, offset: number): [DecodedValueOf<TCoders>, number] {\n    if (!this.#hasNestedOption && data.length < this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid tuple data size.`);\n    }\n\n    let newOffset = offset;\n    const decodedValue = this.coders.map((coder) => {\n      let decoded;\n      [decoded, newOffset] = coder.decode(data, newOffset);\n\n      return decoded;\n    });\n\n    return [decodedValue as DecodedValueOf<TCoders>, newOffset];\n  }\n}\n","sourceCodeStart":22,"sourceCodeEnd":54,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/coders/TupleCoder.ts#L22-L54","documentation":"Thrown by TupleCoder.decode() when the tuple has no nested Option fields and the data buffer is shorter than the tuple's total encoded length (sum of all element coder lengths). Without nested Options the tuple is fixed-size, so the buffer must be at least that large. Tuples with nested Option fields skip this check.","triggerScenarios":"Decoding a truncated buffer that does not contain all tuple elements' bytes. ABI mismatch. Using the wrong tuple coder for the data format.","commonSituations":"Malformed data from an RPC response. ABI version mismatch. Incorrect buffer slicing before decode.","solutions":["Verify data.length >= tupleCoder.encodedLength before calling decode().","Ensure the tuple coder matches the ABI tuple definition.","Check for data truncation in transit."],"exampleFix":"// before\ntupleCoder.decode(truncatedData, 0); // throws DECODE_ERROR\n\n// after\nif (data.length < tupleCoder.encodedLength) {\n  throw new Error(`Need ${tupleCoder.encodedLength} bytes, got ${data.length}`);\n}\ntupleCoder.decode(data, 0);","handlingStrategy":"validation","validationCode":"function canDecodeTuple(data: Uint8Array, encodedLength: number): boolean {\n  return data.length >= encodedLength;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate buffer size against the tuple encodedLength.","Keep ABI definitions synchronized between contract and client.","Log expected vs actual size on decode failures."],"tags":["abi-coder","decoding","tuple","data-validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}