{"record":{"id":"51abbb202caaafb1","repo":"usebruno/bruno","slug":"getrandomvalues-invalid-or-unsupported-typed-arra","errorCode":null,"errorMessage":"getRandomValues: Invalid or unsupported typed array type: ${obj.type}","messagePattern":"getRandomValues: Invalid or unsupported typed array type: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bruno-js/src/sandbox/quickjs/shims/lib/utils.js","lineNumber":30,"sourceCode":"    'Int8Array',\n    'Uint8Array',\n    'Uint8ClampedArray',\n    'Int16Array',\n    'Uint16Array',\n    'Int32Array',\n    'Uint32Array',\n    'Float32Array',\n    'Float64Array',\n    'BigInt64Array',\n    'BigUint64Array'\n  ]);\n\n  if (!obj || typeof obj !== 'object') {\n    throw new TypeError('getRandomValues: Invalid typed array object');\n  }\n\n  if (typeof obj.type !== 'string' || !allowedConstructors.has(obj.type)) {\n    throw new TypeError(`getRandomValues: Invalid or unsupported typed array type: ${obj.type}`);\n  }\n\n  if (!obj.array || typeof obj.length !== 'number') {\n    throw new TypeError('getRandomValues: Invalid typed array properties');\n  }\n\n  const ctor = globalThis[obj.type];\n  if (typeof ctor !== 'function') {\n    throw new TypeError(`getRandomValues: Constructor ${obj.type} is not available`);\n  }\n\n  return new ctor(obj.array, 0, obj.length);\n}\n\nmodule.exports = {\n  serializeTypedArray,\n  deserializeTypedArray\n};","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-js/src/sandbox/quickjs/shims/lib/utils.js#L12-L48","documentation":"Thrown by deserializeTypedArray when the serialized object's `type` field is missing, not a string, or not one of the allowed typed-array constructor names (Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array). The check is an allowlist — anything outside the set is rejected.","triggerScenarios":"A custom object hand-rolled to look like the serialized shape but with a wrong/missing `type`; an attempt to pass a DataView or a non-typed array; corruption of the serialized payload across the QuickJS marshalling boundary.","commonSituations":"Trying crypto.getRandomValues with a DataView (not supported); passing a plain Array; the constructor name on the host side differs (e.g. a polyfilled Uint8Array subclass).","solutions":["Use one of the supported typed arrays directly: `new Uint8Array(n)`.","Avoid hand-building the serialized object — let serializeTypedArray produce it.","If using a subclass, pass the underlying base typed array instead."],"exampleFix":"// before — DataView is not in the allowlist\ncrypto.getRandomValues(new DataView(buf));\n\n// after\ncrypto.getRandomValues(new Uint8Array(buf));","handlingStrategy":"type-guard","validationCode":"const ALLOWED = new Set(['Int8Array','Uint8Array','Uint8ClampedArray','Int16Array','Uint16Array','Int32Array','Uint32Array','Float32Array','Float64Array','BigInt64Array','BigUint64Array']);\nfunction assertType(name) { if (!ALLOWED.has(name)) throw new TypeError('bad type ' + name); }","typeGuard":"const isAllowedType = (v) => typeof v === 'string' && ALLOWED.has(v);","tryCatchPattern":"try { crypto.getRandomValues(arr); }\ncatch (err) {\n  if (/Invalid or unsupported typed array type/.test(err.message)) {\n    crypto.getRandomValues(new Uint8Array(arr));\n  } else throw err;\n}","preventionTips":["Stick to Uint8Array for random bytes.","Do not pass DataView or hand-rolled serialized objects."],"tags":["bruno-js","quickjs","sandbox","crypto","webcrypto","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}