gchq/CyberChef · error · OperationError
Invalid file type.
Error message
Invalid file type.
What it means
Thrown at the top of RotateImage.run() when isImage(input) returns falsy, meaning the input ArrayBuffer's magic bytes are not a recognised image type. This guard runs before Jimp.read() so non-image input is rejected cheaply.
Source
Thrown at src/core/operations/RotateImage.mjs:50
this.args = [
{
name: "Rotation amount (degrees)",
type: "number",
value: 90,
},
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
async run(input, args) {
const [degrees] = args;
if (!isImage(input)) {
throw new OperationError("Invalid file type.");
}
let image;
try {
image = await Jimp.read(input);
} catch (err) {
throw new OperationError(`Error loading image. (${err})`);
}
try {
if (isWorkerEnvironment())
self.sendStatusMessage("Rotating image...");
image.rotate(degrees);
let imageBuffer;
if (image.mime === "image/gif") {
imageBuffer = await image.getBuffer(JimpMime.png);
} else {
imageBuffer = await image.getBuffer(image.mime);View on GitHub (pinned to 4290ea7539)
Solutions
- Confirm the input is a supported image (PNG, JPEG, GIF, BMP, TIFF, WebP) using a hex viewer or the 'Detect File Type' operation.
- Insert a 'Render Image' or 'Detect File Type' step before Rotate Image to verify the buffer.
- Convert the source to PNG/JPEG before rotating if it is an unsupported but valid image format.
Defensive patterns
Strategy: validation
Validate before calling
import { isImage } from "src/core/lib/FileType.mjs";
function ensureImage(buf) {
const arr = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
if (!isImage(arr)) throw new TypeError("Input is not a recognised image type");
return buf;
} Type guard
function isImageInput(buf) {
return buf instanceof ArrayBuffer && isImage(new Uint8Array(buf)) !== null;
} Prevention
- Run 'Detect File Type' before Rotate Image to confirm the magic bytes.
- Convert the source to PNG/JPEG if it is an unsupported but valid image format.
When it happens
Trigger: Passing a text, archive, audio, or other non-image ArrayBuffer to Rotate Image; passing an image format FileType detection does not support.
Common situations: Feeding the wrong operation output into Rotate Image; a recipe where an upstream decode fails silently leaving non-image bytes; obscure image formats not in the FileType signature table.
Related errors
- Invalid file type.
- Invalid file type.
- Invalid file type.
- Invalid file type.
- Unsupported file type (supported: jpg,png,pbm,bmp) or no fil
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/5e2ee5b983d4eb52.
Report an issue: GitHub.