{"record":{"id":"244c41b4a3758180","repo":"FuelLabs/fuels-ts","slug":"decode-error-244c41","errorCode":"DECODE_ERROR","errorMessage":"Invalid boolean data size.","messagePattern":"Invalid boolean data size\\.","errorType":"error_code","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-coder/src/encoding/coders/BooleanCoder.ts","lineNumber":35,"sourceCode":"    const encodedLength = options.padToWordSize ? WORD_SIZE : 1;\n    super('boolean', 'boolean', encodedLength);\n\n    this.options = options;\n  }\n\n  encode(value: boolean): Uint8Array {\n    const isTrueBool = value === true || value === false;\n\n    if (!isTrueBool) {\n      throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);\n    }\n\n    return toBytes(value ? 1 : 0, this.encodedLength);\n  }\n\n  decode(data: Uint8Array, offset: number): [boolean, number] {\n    if (data.length < this.encodedLength) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);\n    }\n\n    const bytes = bn(data.slice(offset, offset + this.encodedLength));\n\n    if (bytes.isZero()) {\n      return [false, offset + this.encodedLength];\n    }\n\n    if (!bytes.eq(bn(1))) {\n      throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`);\n    }\n\n    return [true, offset + this.encodedLength];\n  }\n}\n","sourceCodeStart":17,"sourceCodeEnd":51,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-coder/src/encoding/coders/BooleanCoder.ts#L17-L51","documentation":"Thrown by BooleanCoder.decode at the top guard: data.length < this.encodedLength. encodedLength is 1 by default, or WORD_SIZE (8) when padToWordSize is set. Message: \"Invalid boolean data size.\". The buffer is too short to hold even one boolean value.","triggerScenarios":"Calling bool.decode(data, offset) with data shorter than the expected length (1 byte, or 8 bytes when padded). Common with truncated payloads or wrong offset.","commonSituations":"Truncated receipt/log data; using a padded boolean coder against unpadded data (or vice-versa); manual offset advanced past available bytes.","solutions":["Confirm data.length >= this.encodedLength before decode.","Ensure the boolean's padToWordSize option matches how the data was encoded.","Use the high-level decoder to track offsets and padding automatically."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (data.length < boolCoder.encodedLength) throw new Error('buffer too short for boolean')\nbool.decode(data, offset)","typeGuard":"const canDecodeBoolean = (data: Uint8Array, len: number) => data.length >= len","tryCatchPattern":"try { bool.decode(data, offset) }\ncatch (e) { if ((e as FuelError).code === ErrorCode.DECODE_ERROR) { /* check length/padding */ } throw e }","preventionTips":["Match the coder's padToWordSize to how the data was encoded.","Validate buffer length before decode.","Use the framework decoder for consistent padding handling."],"tags":["abi-coder","decoding","boolean","data-length"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}