{"record":{"id":"a97f0ef7d4044881","repo":"FuelLabs/fuels-ts","slug":"data-section-offset-is-out-of-bounds-offset-of","errorCode":null,"errorMessage":"Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}","messagePattern":"Data section offset is out of bounds, offset: (.+?), binary length: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/account/src/utils/predicate-script-loader-instructions.ts","lineNumber":154,"sourceCode":"    // REG_GENERAL_USE to hold the size of the blob.\n    asm.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),\n    // Push the blob contents onto the stack.\n    asm.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),\n    // Jump into the memory where the contract is loaded.\n    // What follows is called _jmp_mem by the sway compiler.\n    // Subtract the address contained in IS because jmp will add it back.\n    asm.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),\n    // jmp will multiply by 4, so we need to divide to cancel that out.\n    asm.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),\n    // Jump to the start of the contract we loaded.\n    asm.jmp(REG_START_OF_LOADED_CODE),\n  ];\n\n  const offset = getBytecodeConfigurableOffset(originalBinary);\n\n  // if the binary length is smaller than the offset\n  if (originalBinary.length < offset) {\n    throw new Error(\n      `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`\n    );\n  }\n\n  // Extract the configurable section from the binary (slice from the configurable offset onwards)\n  const configurableSection = originalBinary.slice(offset);\n\n  // Check if the configurable section is non-empty\n  if (configurableSection.length > 0) {\n    // Get the number of instructions (assuming it won't exceed u16::MAX)\n    const numOfInstructions = getInstructions(0).length;\n    if (numOfInstructions > 65535) {\n      throw new Error('Too many instructions, exceeding u16::MAX.');\n    }\n\n    // Convert instructions to bytes\n    const instructionBytes = new Uint8Array(\n      getInstructions(numOfInstructions).flatMap((instruction) =>","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/utils/predicate-script-loader-instructions.ts#L136-L172","documentation":"Thrown by getPredicateScriptLoaderInstructions() when the configurable-section offset decoded from the bytecode exceeds the bytecode's actual byte length. The offset is read via a u64 decode at CONFIGURABLE_OFFSET_INDEX (byte 16); if the bytecode is truncated, malformed, or not actual compiled Sway output, the offset will be garbage and point past the end.","triggerScenarios":"Passing corrupted, truncated, or non-Sway bytecode to deployScriptOrPredicate or getPredicateScriptLoaderInstructions. Also triggered by bytecode from an incompatible Sway compiler version that lays out the configurable offset header differently than the SDK expects.","commonSituations":"Loading bytecode from a truncated file; passing raw source instead of compiled binary; version skew between forc/Sway compiler and fuels-ts SDK; manually constructing a Uint8Array of the wrong length; bytecode pipeline dropping bytes during transport (e.g. base64 decode mismatch).","solutions":["Recompile the predicate/script with the forc version matched to your SDK release.","Verify the bytecode Uint8Array length matches the on-disk .bin file exactly.","Load bytecode directly from the build artifact rather than reconstructing it.","Check for truncation in any transport/encoding layer (base64, hex, JSON)."],"exampleFix":"// before\nconst bytecode = new Uint8Array(partialBuffer); // truncated\n// after\nconst bytecode = await fs.readFile('./project/out/debug/predicate.bin');","handlingStrategy":"validation","validationCode":"import { getBytecodeConfigurableOffset } from '@fuel-ts/account/utils';\nconst offset = getBytecodeConfigurableOffset(bytecode);\nif (bytecode.length < offset) throw new Error('Bytecode shorter than configurable offset');","typeGuard":"const isCompleteBytecode = (b: Uint8Array): boolean => { try { return b.length >= getBytecodeConfigurableOffset(b); } catch { return false; } };","tryCatchPattern":null,"preventionTips":["Read bytecode directly from the forc build artifact (.bin).","Keep forc/Sway and fuels-ts versions in lockstep.","Verify byte length after any transport/encoding step."],"tags":["predicate","bytecode","deployment","compiler","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}