gchq/CyberChef · error · OperationError
Invalid file type.
Error message
Invalid file type.
What it means
BlurImage runs an isImage() check on the input ArrayBuffer before processing. If the bytes are not recognized as a supported image type it throws 'Invalid file type.' immediately, before Jimp is invoked.
Source
Thrown at src/core/operations/BlurImage.mjs:56
},
{
name: "Type",
type: "option",
value: ["Fast", "Gaussian"],
},
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
*/
async run(input, args) {
const [blurAmount, blurType] = 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 {
switch (blurType) {
case "Fast":
if (isWorkerEnvironment())
self.sendStatusMessage("Fast blurring image...");
image.blur(blurAmount);
break;
case "Gaussian":
if (isWorkerEnvironment())
self.sendStatusMessage("Gaussian blurring image...");View on GitHub (pinned to 4290ea7539)
Solutions
- Confirm the input is a supported image (PNG/JPEG/BMP/etc.) by checking magic bytes before invoking.
- Re-fetch or re-export the file if it may be truncated.
- Route non-image files to the correct operation instead of BlurImage.
Example fix
// before BlurImage.run(textBuffer, args) // after BlurImage.run(pngBuffer, args)
Defensive patterns
Strategy: type-guard
Validate before calling
if (!isImage(input)) throw new Error('Input is not a supported image'); Type guard
function isLikelyImage(buf) { return isImage(buf) !== false; } Try / catch
try { blurImage.run(input, args); }
catch (e) { if (/Invalid file type/.test(e.message)) { /* route to correct op */ } else throw e; } Prevention
- Check magic bytes (PNG/JPEG/BMP/GIF) before invoking.
- Validate file type at the upload boundary.
- Do not chain arbitrary operations into image operations.
When it happens
Trigger: Calling BlurImage.run with an input ArrayBuffer whose magic bytes are not a supported image format (e.g. a text file, PDF, or corrupted header).
Common situations: Piping non-image data into the operation; uploading the wrong file; truncated download whose magic bytes are gone; a format isImage() does not recognize.
Related errors
- Invalid file type.
- Invalid file type.
- Invalid file type.
- Unsupported file type (supported: jpg,png,pbm,bmp) or no fil
- Invalid file type.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/c534557a06d9984f.
Report an issue: GitHub.