{"record":{"id":"7dca091dcf460b27","repo":"FuelLabs/fuels-ts","slug":"invalid-data","errorCode":"INVALID_DATA","errorMessage":"invalid data:${nameMessage} ${value}\nIf you are attempting to transform a hex value, please make sure it is being passed as a string and wrapped in quotes.","messagePattern":"invalid data:(.+?) (.+?)\nIf you are attempting to transform a hex value, please make sure it is being passed as a string and wrapped in quotes\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/utils/arrayify.ts","lineNumber":33,"sourceCode":"    if (copy) {\n      return new Uint8Array(value);\n    }\n    return value;\n  }\n\n  if (typeof value === 'string' && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {\n    const result = new Uint8Array((value.length - 2) / 2);\n    let offset = 2;\n    for (let i = 0; i < result.length; i++) {\n      result[i] = parseInt(value.substring(offset, offset + 2), 16);\n      offset += 2;\n    }\n    return result;\n  }\n\n  const nameMessage = name ? ` ${name} -` : '';\n  const message = `invalid data:${nameMessage} ${value}\\nIf you are attempting to transform a hex value, please make sure it is being passed as a string and wrapped in quotes.`;\n  throw new FuelError(ErrorCode.INVALID_DATA, message);\n};\n","sourceCodeStart":15,"sourceCodeEnd":35,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/utils/src/utils/arrayify.ts#L15-L35","documentation":"Thrown by arrayify when the input value is neither a Uint8Array nor a string matching the strict hex regex /^0x([0-9a-f][0-9a-f])*$/i. The regex requires an even number of hex digits prefixed with exactly '0x'. Any other shape (odd-length hex, missing prefix, number, object) is treated as invalid data.","triggerScenarios":"Calling arrayify(value) with: a hex string lacking the '0x' prefix (e.g. 'deadbeef'), a hex string with an odd number of digits (e.g. '0xabc'), a plain number, a boolean, an object, or undefined. The nameMessage includes the optional 'name' argument for context.","commonSituations":"Passing a number where a hex string is expected. Forgetting quotes around a hex literal in config/JSON (parses as a number). Concatenating hex fragments and ending up with an odd digit count. Copy-pasting a hex value without the '0x' prefix. Calling low-level utils directly with data from an untyped source.","solutions":["Pass the value as a string with an '0x' prefix and an even number of hex digits (e.g. '0xdeadbeef').","If you have a number, convert it first: '0x' + value.toString(16) (and pad to even length).","Wrap hex literals in quotes in JSON/config so they are not parsed as numbers.","Validate with a regex before calling arrayify when data is untrusted."],"exampleFix":"// before\narrayify(deadbeef);        // ReferenceError / not a string\narrayify('abc');           // no 0x prefix\narrayify('0xabc');         // odd length\n\n// after\narrayify('0xdeadbeef');    // valid: prefixed, even length\narrayify(new Uint8Array([0xde, 0xad, 0xbe, 0xef]));","handlingStrategy":"validation","validationCode":"const HEX_RE = /^0x([0-9a-f][0-9a-f])*$/i;\nfunction isBytesLike(v: unknown): v is Uint8Array | string {\n  return v instanceof Uint8Array || (typeof v === 'string' && HEX_RE.test(v));\n}\nif (!isBytesLike(value)) throw new Error('expected Uint8Array or 0x-prefixed even-length hex');\narrayify(value);","typeGuard":"const isHexBytes = (v: unknown): v is string =>\n  typeof v === 'string' && /^0x([0-9a-f][0-9a-f])*$/i.test(v);","tryCatchPattern":"try {\n  const bytes = arrayify(value, 'myField');\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INVALID_DATA) {\n    // coerce or reject the bad input\n  }\n  throw e;\n}","preventionTips":["Always pass hex as a quoted string with an '0x' prefix and even digit count.","Convert numbers to hex strings before passing to byte utilities.","Pre-validate untrusted input with the hex regex."],"tags":["arrayify","hex","bytes","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}