gchq/CyberChef · error · OperationError

Invalid input file type.

Error message

Invalid input file type.

What it means

Thrown by Flip Image when isImage(input) returns a falsy value, meaning the input ArrayBuffer's magic bytes do not match any recognized image format. The operation requires a supported raster image before handing the buffer to Jimp. This is a pre-flight format check that runs before any decoding attempt.

Source

Thrown at src/core/operations/FlipImage.mjs:48

        this.presentType = "html";
        this.args = [
            {
                name: "Axis",
                type: "option",
                value: ["Horizontal", "Vertical"],
            },
        ];
    }

    /**
     * @param {ArrayBuffer} input
     * @param {Object[]} args
     * @returns {byteArray}
     */
    async run(input, args) {
        const [flipAxis] = args;
        if (!isImage(input)) {
            throw new OperationError("Invalid input file type.");
        }

        let image;
        try {
            image = await Jimp.read(input);
        } catch (err) {
            throw new OperationError(`Error loading image. (${err})`);
        }
        try {
            if (isWorkerEnvironment())
                self.sendStatusMessage("Flipping image...");
            switch (flipAxis) {
                case "Horizontal":
                    image.flip({
                        horizontal: true,
                        vertical: false,
                    });
                    break;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Ensure the upstream operation outputs an ArrayBuffer of raw image bytes (use From Base64 / From Hex first if needed).
  2. Confirm the file is a raster format Jimp supports (PNG, JPEG, BMP, GIF, TIFF).
  3. Check the file header is intact and not truncated.
  4. Verify the recipe chain does not pass a string-typed output into this ArrayBuffer input.

Example fix

// before: passing raw base64 text
flip.run(base64String, ['Horizontal']) // not bytes
// after: decode to ArrayBuffer first
const buf = await fromBase64Op.run(base64String, ...);
flip.run(buf, ['Horizontal'])
Defensive patterns

Strategy: validation

Validate before calling

import { isImage } from "../lib/FileType.mjs";
// Confirm input is a recognized image before flipping
if (!isImage(new Uint8Array(input))) {
  // skip or convert; do not call flip.run()
}

Type guard

function isLikelyImage(buf) {
  return !!isImage(buf instanceof ArrayBuffer ? new Uint8Array(buf) : buf);
}

Try / catch

try {
  await flip.run(input, args);
} catch (e) {
  if (e.type === 'OperationError' && /Invalid input file type/.test(e.message)) {
    // input is not an image; inform user or convert
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a non-image ArrayBuffer (text, PDF, audio, executable); passing an image format Jimp/CyberChef does not recognize; passing an empty or truncated buffer whose magic bytes are missing; feeding a string when an ArrayBuffer is expected.

Common situations: Recipe input type mismatch (e.g. text feeding into an image op); dropping a file whose header is stripped; SVG or HEIC files which are not raster decoders CyberChef recognizes; clipboard paste of base64 text that was not first decoded to bytes.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/e4b1dfb85de67c2c. Report an issue: GitHub.