{"record":{"id":"71000cf073985987","repo":"gchq/CyberChef","slug":"invalid-file-type-71000c","errorCode":null,"errorMessage":"Invalid file type","messagePattern":"Invalid file type","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/RenderImage.mjs","lineNumber":79,"sourceCode":"        // Convert input to raw bytes\n        switch (inputFormat) {\n            case \"Hex\":\n                input = fromHex(input);\n                break;\n            case \"Base64\":\n                // Don't trust the Base64 entered by the user.\n                // Unwrap it first, then re-encode later.\n                input = fromBase64(input, undefined, \"byteArray\");\n                break;\n            case \"Raw\":\n            default:\n                input = Utils.strToByteArray(input);\n                break;\n        }\n\n        // Determine file type\n        if (!isImage(input)) {\n            throw new OperationError(\"Invalid file type\");\n        }\n\n        return input;\n    }\n\n    /**\n     * Displays the image using HTML for web apps.\n     *\n     * @param {byteArray} data\n     * @returns {html}\n     */\n    async present(data) {\n        if (!data.length) return \"\";\n\n        let dataURI = \"data:\";\n\n        // Determine file type\n        const mime = isImage(data);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/RenderImage.mjs#L61-L97","documentation":"Thrown by RenderImage.run when the processed input (after optional Base64 decoding) is not recognized as a supported image format by isImage(). The run stage extracts/normalizes bytes before presentation; if no known image signature matches, it refuses to proceed.","triggerScenarios":"Supplying non-image bytes; selecting the wrong input format (e.g. 'Base64' when the input is raw bytes); corrupted/truncated image; unsupported format.","commonSituations":"Mismatched input format dropdown; piping a non-image operation's output into RenderImage; truncated copy-paste of image data.","solutions":["Ensure the input is a supported image (PNG/JPEG/GIF/BMP).","Match the input format option to the actual encoding (Raw vs Base64).","Re-acquire the full image bytes if truncation is suspected.","Insert a 'From Base64'/'From Hex' step if the bytes are still encoded."],"exampleFix":"// before\n//   input format: Raw, but data is base64 text\n// after\n//   input format: Base64","handlingStrategy":"type-guard","validationCode":"if (!isImage(input)) throw new Error('Input is not a supported image type');","typeGuard":"const isSupportedImage = buf => Boolean(isImage(buf));","tryCatchPattern":"try { op.run(input); } catch (e) { if (/Invalid file type/.test(e.message)) fixInputEncoding(); else throw e; }","preventionTips":["Match the input format option to the data.","Decode Base64/Hex upstream."],"tags":["image","render","validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}