{"record":{"id":"6e87d30e9bdeff88","repo":"BabylonJS/Babylon.js","slug":"zlib-preset-dictionary-not-supported","errorCode":null,"errorMessage":"zlib: preset dictionary not supported","messagePattern":"zlib: preset dictionary not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/FBX/parsers/zlibInflate.ts","lineNumber":31,"sourceCode":" *\r\n * This implementation is intentionally scoped to FBX binary array payloads: one-shot,\r\n * synchronous zlib streams with the exact uncompressed length known up front.\r\n */\r\nexport function inflateZlib(input: Uint8Array, expectedLength: number): Uint8Array {\r\n    if (!Number.isInteger(expectedLength) || expectedLength < 0) {\r\n        throw new Error(\"zlib: invalid expected length\");\r\n    }\r\n    if (input.byteLength < 6) {\r\n        throw new Error(\"zlib: unexpected end of input\");\r\n    }\r\n\r\n    const cmf = input[0];\r\n    const flg = input[1];\r\n    if ((cmf & 0x0f) !== 8 || cmf >> 4 > 7 || ((cmf << 8) + flg) % 31 !== 0) {\r\n        throw new Error(\"zlib: invalid header\");\r\n    }\r\n    if ((flg & 0x20) !== 0) {\r\n        throw new Error(\"zlib: preset dictionary not supported\");\r\n    }\r\n\r\n    const reader = new BitReader(input, 2, input.byteLength - 4);\r\n    const output = new OutputWriter(expectedLength);\r\n\r\n    let isFinalBlock = false;\r\n    while (!isFinalBlock) {\r\n        isFinalBlock = reader.readBits(1) === 1;\r\n        const blockType = reader.readBits(2);\r\n        switch (blockType) {\r\n            case 0:\r\n                inflateStoredBlock(reader, output);\r\n                break;\r\n            case 1:\r\n                inflateCompressedBlock(reader, output, getFixedLiteralLengthTree(), getFixedDistanceTree());\r\n                break;\r\n            case 2: {\r\n                const { literalLengthTree, distanceTree } = readDynamicTrees(reader);\r","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/FBX/parsers/zlibInflate.ts#L13-L49","documentation":"A zlib FLG byte with bit 0x20 set declares a preset dictionary (FDICT flag). This lightweight one-shot inflater does not implement preset dictionaries and throws immediately. FBX files should never use preset dictionaries, so encountering one indicates unusual or hand-modified compressed data.","triggerScenarios":"parseArrayProperty inflating an FBX array payload whose zlib header has FDICT set — i.e., data compressed with zlib with a custom dictionary.","commonSituations":"Data compressed by a non-standard tool configured with a zlib dictionary; hand-crafted or post-processed FBX payloads; generic zlib data embedded into an FBX file by a custom pipeline.","solutions":["Recompress the payload with plain zlib (no dictionary) and rebuild or re-export the FBX","Use a full zlib implementation (e.g., pako/DecompressionStream with dictionary support) if you must consume such data","Confirm the exporter producing the FBX uses default zlib settings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if ((compressed[1] & 0x20) !== 0) {\n  throw new Error('FBX array uses zlib preset dictionary, which is unsupported');\n}","typeGuard":"function usesPresetDictionary(b: Uint8Array): boolean {\n  return b.byteLength >= 2 && (b[1] & 0x20) !== 0;\n}","tryCatchPattern":"try {\n  return inflateZlib(compressed, expectedLength);\n} catch (e) {\n  if ((e as Error).message === 'zlib: preset dictionary not supported') {\n    throw new Error('Unsupported zlib dictionary in FBX array — re-export the asset', { cause: e });\n  }\n  throw e;\n}","preventionTips":["Reject FDICT-flagged payloads early with a clear message","Configure your compression pipeline to use default zlib settings (no dictionary)","Detect the flag at ingest time, before heavy parsing"],"tags":["zlib","compression","unsupported-feature","fbx"],"backgroundTag":"unsupported-compression-feature","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}