{"record":{"id":"4d8b227caa31cf4d","repo":"BabylonJS/Babylon.js","slug":"deflate-invalid-code-length-symbol","errorCode":null,"errorMessage":"deflate: invalid code length symbol","messagePattern":"deflate: invalid code length symbol","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/FBX/parsers/zlibInflate.ts","lineNumber":392,"sourceCode":"        let repeatedValue: number;\r\n        switch (symbol) {\r\n            case 16:\r\n                if (lengths.length === 0) {\r\n                    throw new Error(\"deflate: invalid code length repeat\");\r\n                }\r\n                repeatedValue = lengths[lengths.length - 1];\r\n                repeatLength = reader.readBits(2) + 3;\r\n                break;\r\n            case 17:\r\n                repeatedValue = 0;\r\n                repeatLength = reader.readBits(3) + 3;\r\n                break;\r\n            case 18:\r\n                repeatedValue = 0;\r\n                repeatLength = reader.readBits(7) + 11;\r\n                break;\r\n            default:\r\n                throw new Error(\"deflate: invalid code length symbol\");\r\n        }\r\n\r\n        if (lengths.length + repeatLength > count) {\r\n            throw new Error(\"deflate: invalid code length repeat\");\r\n        }\r\n        for (let i = 0; i < repeatLength; i++) {\r\n            lengths.push(repeatedValue);\r\n        }\r\n    }\r\n    return lengths;\r\n}\r\n","sourceCodeStart":374,"sourceCodeEnd":404,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/FBX/parsers/zlibInflate.ts#L374-L404","documentation":"The code-length alphabet in a dynamic block only permits symbols 0-18; the tree is built from 19 lengths, so this default branch is defensive — it fires if decode somehow returns a symbol outside 0-18 (should be impossible with a valid tree), signalling internal corruption of the decoded lengths. Practically, it surfaces on the same corrupt/misaligned streams as the other huffman errors.","triggerScenarios":"readCodeLengths decodes a symbol >18 from the code-length tree during a type-2 block — only reachable if the tree was built from data that assigned codes to out-of-range symbols, i.e. deeply corrupt input.","commonSituations":"Severely corrupted FBX payloads; a bitstream that is not deflate at all but passed earlier header checks; bug in custom tooling that rewrote compressed array bytes.","solutions":["Validate the payload independently with python zlib.decompress to confirm corruption","Re-export or re-download the FBX file","Audit any pipeline step that touches compressed array bytes in the FBX binary","If reproducible on valid files, report with the failing payload bytes — the loader's code-length tree construction may need hardening"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try { decompressSync(payload); } catch (e) {\n  throw new Error(\"Payload rejected by reference zlib decoder — FBX file corrupt\", { cause: e as Error });\n}","typeGuard":null,"tryCatchPattern":"try {\n  const out = inflateZlib(payload, expectedLength);\n} catch (e) {\n  if (e instanceof Error && e.message === \"deflate: invalid code length symbol\") {\n    throw new Error(\"Out-of-range code-length symbol — deeply corrupt FBX payload\", { cause: e });\n  }\n  throw e;\n}","preventionTips":["Cross-validate with a mature zlib implementation before suspecting the custom inflater","Audit pipelines that post-process FBX binaries for accidental byte rewriting","Hash-verify assets at download time"],"tags":["deflate","dynamic-huffman","corrupt-data","fbx"],"backgroundTag":"invalid-huffman-table","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}