{"record":{"id":"809f11e3d8d6cb19","repo":"gchq/CyberChef","slug":"unable-to-find-decompression-function","errorCode":null,"errorMessage":"Unable to find decompression function","messagePattern":"Unable to find decompression function","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/LZStringDecompress.mjs","lineNumber":49,"sourceCode":"                name: \"Compression Format\",\n                type: \"option\",\n                defaultIndex: 0,\n                value: COMPRESSION_OUTPUT_FORMATS\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const decompress = DECOMPRESSION_FUNCTIONS[args[0]];\n        if (decompress) {\n            return decompress(input);\n        } else {\n            throw new OperationError(\"Unable to find decompression function\");\n        }\n    }\n\n\n}\n\nexport default LZStringDecompress;\n","sourceCodeStart":31,"sourceCodeEnd":57,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/LZStringDecompress.mjs#L31-L57","documentation":"Thrown by LZString Decompress when the selected format has no entry in the DECOMPRESSION_FUNCTIONS map. Same defensive pattern as the compress operation: the dropdown binds the option to known formats, and this fires only for an out-of-map value or a missing args[0].","triggerScenarios":"A recipe supplies a format string not in DECOMPRESSION_FUNCTIONS. Drift between the options list and the decompression map. Programmatic call passing an unrecognised format. args[0] undefined.","commonSituations":"Hand-editing the recipe option. Version mismatch importing recipes. Editing the format list without updating the function map.","solutions":["Choose a format from the dropdown so it matches a known decompressor.","Validate against Object.keys(DECOMPRESSION_FUNCTIONS) before calling programmatically.","Keep the formats list and the functions map aligned when maintaining the module.","Ensure the decompress format matches the format the data was compressed with."],"exampleFix":"// before: format mismatch\nchef.LZStringDecompress(data, ['UnknownFormat']);\n// after: matching decompressor\nchef.LZStringDecompress(data, ['Base64']);","handlingStrategy":"validation","validationCode":"function ensureDecompressionFormat(format) {\n  if (!Object.prototype.hasOwnProperty.call(DECOMPRESSION_FUNCTIONS, format))\n    throw new Error(`Unknown LZ decompression format: ${format}`);\n  return format;\n}","typeGuard":"function isKnownDecompressionFormat(f) {\n  return Object.prototype.hasOwnProperty.call(DECOMPRESSION_FUNCTIONS, f);\n}","tryCatchPattern":"try {\n  return chef.LZStringDecompress(input, [format]);\n} catch (e) {\n  if (/Unable to find decompression function/.test(e.message))\n    throw new Error('Pick a format listed in the dropdown, matching the compression');\n  throw e;\n}","preventionTips":["Pick the format from the dropdown and match it to how the data was compressed.","Keep the formats list and the functions map aligned.","Validate the key exists before calling programmatically."],"tags":["lzstring","compression","argument-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}