{"record":{"id":"1e4734c6e5d0598f","repo":"FuelLabs/fuels-ts","slug":"decode-error-1e4734","errorCode":"DECODE_ERROR","errorMessage":"Invalid enum data size.","messagePattern":"Invalid enum data size\\.","errorType":"error_code","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/coders/EnumCoder.ts","lineNumber":93,"sourceCode":"        .join(', ');\n      throw new FuelError(\n        ErrorCode.INVALID_DECODE_VALUE,\n        `Invalid case '${caseKey}'. Valid cases: ${validCases}.`\n      );\n    }\n\n    const encodedValue = valueCoder.encode(value[caseKey]);\n\n    return new Uint8Array([...this.#caseIndexCoder.encode(caseIndex), ...encodedValue]);\n  }\n\n  #decodeNativeEnum(caseKey: string, newOffset: number): [DecodedValueOf<TCoders>, number] {\n    return [caseKey as unknown as DecodedValueOf<TCoders>, newOffset];\n  }\n\n  decode(data: Uint8Array, offset: number): [DecodedValueOf<TCoders>, number] {\n    if (this.#shouldValidateLength && data.length < this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);\n    }\n\n    const caseBytes = new BigNumberCoder('u64').decode(data, offset)[0];\n    const caseIndex = toNumber(caseBytes);\n    const caseKey = Object.keys(this.coders)[caseIndex];\n    if (!caseKey) {\n      throw new FuelError(\n        ErrorCode.INVALID_DECODE_VALUE,\n        `Invalid caseIndex \"${caseIndex}\". Valid cases: ${Object.keys(this.coders)}.`\n      );\n    }\n    const valueCoder = this.coders[caseKey];\n    const offsetAndCase = offset + this.#caseIndexCoder.encodedLength;\n\n    if (this.#shouldValidateLength && data.length < offsetAndCase + valueCoder.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);\n    }\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/coders/EnumCoder.ts#L75-L111","documentation":"Thrown by EnumCoder.decode at the first length guard: this.#shouldValidateLength is true and data.length < this.encodedLength. encodedLength is the case-index (8) plus the minimum value size. Message: \"Invalid enum data size.\". Note length validation is skipped for Option/nested-option enums (#shouldValidateLength is false), so this only fires for regular enums.","triggerScenarios":"Decoding a non-Option enum from a buffer shorter than the enum's encoded length (case index + value). Common with truncated return data or wrong coder.","commonSituations":"Truncated receipt/return data; decoding at a wrong offset; using a regular-enum coder on data that is actually an Option; provider truncation.","solutions":["Confirm data.length >= enumCoder.encodedLength before decode.","Verify you are using the correct enum coder for the data.","Let the high-level decoder manage offsets."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (enumCoder['#shouldValidateLength'] !== false && data.length < enumCoder.encodedLength) {\n  throw new Error('buffer too short for enum')\n}\nenumCoder.decode(data, offset)","typeGuard":"const canDecodeEnum = (data: Uint8Array, len: number) => data.length >= len","tryCatchPattern":"try { enumCoder.decode(data, offset) }\ncatch (e) { if ((e as FuelError).code === ErrorCode.DECODE_ERROR) { /* truncated payload / wrong coder */ } throw e }","preventionTips":["Confirm the buffer is the full encoded enum.","Use the correct enum coder (regular vs Option).","Prefer the high-level decoder."],"tags":["abi-coder","decoding","enum","data-length"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}