gchq/CyberChef · error · OperationError
Unable to find compression function
Error message
Unable to find compression function
What it means
Thrown by LZString Compress when the selected compression format does not resolve to a function in the COMPRESSION_FUNCTIONS map. The format is a dropdown bound to COMPRESSION_OUTPUT_FORMATS, so this is a defensive guard: it triggers only if the argument is not a key in the map (hand-edited recipe, a format listed in options but missing from the map, or args[0] undefined).
Source
Thrown at src/core/operations/LZStringCompress.mjs:49
name: "Compression Format",
type: "option",
defaultIndex: 0,
value: COMPRESSION_OUTPUT_FORMATS
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const compress = COMPRESSION_FUNCTIONS[args[0]];
if (compress) {
return compress(input);
} else {
throw new OperationError("Unable to find compression function");
}
}
}
export default LZStringCompress;
View on GitHub (pinned to 4290ea7539)
Solutions
- Pick a format from the operation's dropdown (it lists only valid options).
- When calling programmatically, check Object.keys(COMPRESSION_FUNCTIONS) for the format first.
- Keep COMPRESSION_OUTPUT_FORMATS and COMPRESSION_FUNCTIONS in sync when adding formats.
- Reset the option to its default index to recover a valid value.
Example fix
// before: unknown format chef.LZStringCompress(text, ['UnknownFormat']); // after: a format present in the map chef.LZStringCompress(text, ['Base64']);
Defensive patterns
Strategy: validation
Validate before calling
function ensureCompressionFormat(format) {
if (!Object.prototype.hasOwnProperty.call(COMPRESSION_FUNCTIONS, format))
throw new Error(`Unknown LZ compression format: ${format}`);
return format;
} Type guard
function isKnownCompressionFormat(f) {
return Object.prototype.hasOwnProperty.call(COMPRESSION_FUNCTIONS, f);
} Try / catch
try {
return chef.LZStringCompress(input, [format]);
} catch (e) {
if (/Unable to find compression function/.test(e.message))
throw new Error('Pick a format listed in the dropdown');
throw e;
} Prevention
- Choose the format from the operation dropdown.
- Keep COMPRESSION_OUTPUT_FORMATS and COMPRESSION_FUNCTIONS in sync.
- Validate the key exists before calling programmatically.
When it happens
Trigger: A recipe supplies a format string absent from COMPRESSION_FUNCTIONS. A mismatch where a value in COMPRESSION_OUTPUT_FORMATS has no matching entry in COMPRESSION_FUNCTIONS (data/config drift). Programmatic call with an unrecognised format.
Common situations: Hand-editing the recipe's option value. Updating the format list without the function map (or vice versa). Importing recipes from a different CyberChef version.
Related errors
- Unable to find decompression function
- Invalid block type while parsing DEFLATE stream at pos ${str
- Malformed LZNT1 stream: Block too small! Has the stream been
- Malformed LZNT1 stream: Invalid shift!
- Invalid block cipher mode: ${mode}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/8be8df85ac4725af.
Report an issue: GitHub.