{"record":{"id":"2495dcbdf84dd163","repo":"BabylonJS/Babylon.js","slug":"invalid-fbx-array-byte-length-for-type","errorCode":null,"errorMessage":"Invalid FBX array byte length for ${type}","messagePattern":"Invalid FBX array byte length for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/FBX/parsers/fbxBinaryParser.ts","lineNumber":220,"sourceCode":"    ensureRange(bytes, offset, 12, limit, `FBX array property header for ${type}`);\r\n    const arrayLength = view.getUint32(offset, true);\r\n    const encoding = view.getUint32(offset + 4, true); // 0=raw, 1=zlib\r\n    const compressedLength = view.getUint32(offset + 8, true);\r\n    offset += 12;\r\n    const expectedByteLength = arrayLength * elementSize;\r\n    ensureRange(bytes, offset, compressedLength, limit, `FBX array property data for ${type}`);\r\n\r\n    let arrayData: Uint8Array;\r\n    if (encoding === 1) {\r\n        // zlib compressed\r\n        const compressed = bytes.subarray(offset, offset + compressedLength);\r\n        arrayData = inflateZlib(compressed, expectedByteLength);\r\n    } else {\r\n        if (encoding !== 0) {\r\n            throw new Error(`Unsupported FBX array encoding: ${encoding}`);\r\n        }\r\n        if (compressedLength !== expectedByteLength) {\r\n            throw new Error(`Invalid FBX array byte length for ${type}`);\r\n        }\r\n        arrayData = bytes.slice(offset, offset + compressedLength);\r\n    }\r\n\r\n    const arrayBuffer = arrayData.buffer.slice(arrayData.byteOffset, arrayData.byteOffset + arrayData.byteLength);\r\n\r\n    let value: Float32Array | Float64Array | Int32Array | Uint8Array;\r\n    switch (type) {\r\n        case \"float32[]\":\r\n            value = new Float32Array(arrayBuffer);\r\n            break;\r\n        case \"float64[]\":\r\n            value = new Float64Array(arrayBuffer);\r\n            break;\r\n        case \"int32[]\":\r\n            value = new Int32Array(arrayBuffer);\r\n            break;\r\n        case \"boolean[]\":\r","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/FBX/parsers/fbxBinaryParser.ts#L202-L238","documentation":"Thrown by parseArrayProperty in the FBX binary parser when an uncompressed (encoding===0) array property's declared on-disk byte length (compressedLength) does not match the byte length computed from the element count and element size for the declared type. The parser treats this as corrupt/malformed FBX binary data and aborts rather than silently reading the wrong number of elements.","triggerScenarios":"Parsing an FBX binary node property whose record header declares, e.g., 10 doubles (expectedByteLength=80) but compressedLength=72; a truncated or hand-edited FBX file; a writer that computed element count and byte length inconsistently.","commonSituations":"FBX files exported by buggy or non-conformant exporters; files corrupted in transfer (e.g., FTP ASCII mode, partial download); files with mismatched/forged array headers after post-processing; older FBX versions written by tools with length bugs.","solutions":["Re-export the FBX file from the original DCC tool (Blender/Maya/3ds Max) with a current exporter","Verify the file is not truncated or line-ending-mangled in transfer (compare file size/hash with the source)","Open the file in a reference FBX reader (e.g., FBX Converter / fbx-conv) to confirm it is valid","Inspect the offending node record with an FBX hex viewer to see the mismatched length/count fields","If parsing third-party data defensively, catch this error and skip/repair the node rather than failing the whole load"],"exampleFix":"// before\ncatch (e) { throw e; }\n// after\ntry { node = parseFbxBinary(bytes); }\ncatch (e) {\n  if (String(e.message).includes('Invalid FBX array byte length')) {\n    console.warn('Corrupt array property in FBX, skipping node'); node = null;\n  } else throw e;\n}","handlingStrategy":"validation","validationCode":"// inside parseArrayProperty, before slicing\nconst expectedByteLength = count * ELEMENT_SIZES[type];\nif (encoding === 0 && compressedLength !== expectedByteLength) {\n  throw new Error(`Invalid FBX array byte length for ${type}`);\n}","typeGuard":"function isValidArrayHeader(type: string, count: number, len: number): boolean {\n  const size = ELEMENT_SIZES[type];\n  return typeof size === 'number' && count >= 0 && len === count * size;\n}","tryCatchPattern":"try {\n  const { property } = parseArrayProperty(bytes, offset, limit);\n} catch (e) {\n  if ((e as Error).message.startsWith('Invalid FBX array byte length')) {\n    reportCorruptAsset(e); return null;\n  }\n  throw e;\n}","preventionTips":["Recompute expected byte length from count and element size before trusting the header","Validate downloaded FBX files by checksum before parsing","Test the parser against files from multiple exporters"],"tags":["fbx","binary-parsing","corrupt-data","loaders"],"backgroundTag":"corrupt-file-byte-length-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}