gchq/CyberChef · error · OperationError
Unsupported Mode: (${mode})
Error message
Unsupported Mode: (${mode}) What it means
Thrown by GenerateImage when the 'mode' argument is not one of the recognized pixel-format keys: Greyscale, RG, RGB, RGBA, or Bits. The operation maps each mode to a bytes-per-pixel value and refuses unknown modes before processing input. This guards the downstream pixel-writing loop from an out-of-range switch fallthrough.
Source
Thrown at src/core/operations/GenerateImage.mjs:84
/**
* @param {byteArray} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*/
async run(input, args) {
const [mode, scale, width] = args;
input = new Uint8Array(input);
const bytePerPixelMap = {
Greyscale: 1,
RG: 2,
RGB: 3,
RGBA: 4,
Bits: 1 / 8,
};
if (!Object.hasOwn(bytePerPixelMap, mode)) {
throw new OperationError(`Unsupported Mode: (${mode})`);
}
const bytesPerPixel = bytePerPixelMap[mode];
if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
throw new OperationError(
`Number of bytes is not a divisor of ${bytesPerPixel}`,
);
}
const height = Math.ceil(input.length / bytesPerPixel / width);
const image = new Jimp({ width, height });
if (isWorkerEnvironment())
self.sendStatusMessage("Generating image from data...");
if (mode === "Bits") {
let index = 0;View on GitHub (pinned to 4290ea7539)
Solutions
- Set the mode argument to one of: Greyscale, RG, RGB, RGBA, or Bits.
- If building recipes in code, validate that mode is in the allowed set before invoking the operation.
- Check the operation's ingList/config for the current list of supported mode values.
Example fix
// before args[0] = "CMYK"; // after args[0] = "RGBA"; // one of Greyscale|RG|RGB|RGBA|Bits
Defensive patterns
Strategy: type-guard
Validate before calling
const VALID_MODES = ["Greyscale", "RG", "RGB", "RGBA", "Bits"];
if (!VALID_MODES.includes(mode)) {
// reject before calling GenerateImage
} Type guard
function isImageMode(m) {
return ["Greyscale", "RG", "RGB", "RGBA", "Bits"].includes(m);
} Prevention
- Restrict the mode UI control to the five known values.
- When constructing recipes programmatically, assert the mode against the known set.
When it happens
Trigger: Passing a mode string not present in bytePerPixelMap — e.g. 'CMYK', 'BGR', 'GRAY', a typo like 'RBGA', or a localized/case variant. Also triggered if args[0] is undefined or null because the recipe was constructed programmatically without a mode.
Common situations: Programmatically building a recipe and forgetting to set the mode ingredient, or a UI dropdown change that submits a stale enum value after an operation update.
Related errors
- Invalid length type
- Invalid UUID version
- Unknown granularity value: ${granularity}
- Error: Bit argument must be between 0 and 7
- Invalid secret. The input must be a valid base32 string (cha
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/a73d46cdbe0c38b3.
Report an issue: GitHub.