gchq/CyberChef · error · OperationError

Invalid or unrecognised file type

Error message

Invalid or unrecognised file type

What it means

Play Media only handles audio or video. In run(), isType(/^(audio|video)/, input) checks the decoded bytes against CyberChef's file-type magic-byte signatures and returns true only if a matching audio/* or video/* type is found. If no known media signature matches, the op refuses to proceed because present() could not build a playable element.

Source

Thrown at src/core/operations/PlayMedia.mjs:70

        switch (inputFormat) {
            case "Hex":
                input = fromHex(input);
                break;
            case "Base64":
                // Don't trust the Base64 entered by the user.
                // Unwrap it first, then re-encode later.
                input = fromBase64(input, undefined, "byteArray");
                break;
            case "Raw":
            default:
                input = Utils.strToByteArray(input);
                break;
        }


        // Determine file type
        if (!isType(/^(audio|video)/, input)) {
            throw new OperationError("Invalid or unrecognised file type");
        }

        return input;
    }

    /**
     * Displays an audio or video element that may be able to play the media
     * file.
     *
     * @param {byteArray} data Data containing an audio or video file.
     * @returns {string} Markup to display a media player.
     */
    async present(data) {
        if (!data.length) return "";

        const types = detectFileType(data);
        const matches = /^audio|video/.exec(types[0].mime);
        if (!matches) {

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Confirm the input is actually an audio or video file.
  2. Match the 'Input format' arg to your data (Raw / Base64 / Hex) so the magic bytes survive decoding.
  3. For Base64 media, select 'Base64' so it is unwrapped before type detection.
  4. Verify the file plays in a normal player; if CyberChef lacks the signature, it simply cannot play that container.

Example fix

// before: image bytes passed as Raw
run(imageBytesStr, ["Raw"]);  // not audio/video

// after: actual media with correct format
run(mediaBase64, ["Base64"]);
Defensive patterns

Strategy: validation

Validate before calling

import { isType } from "../lib/FileType.mjs";
const bytes = inputFormat === "Hex" ? fromHex(input) : inputFormat === "Base64" ? fromBase64(input, undefined, "byteArray") : Utils.strToByteArray(input);
if (!isType(/^(audio|video)/, bytes)) {
  throw new Error("Input is not a recognised audio or video file");
}
return playMedia.run(input, [inputFormat]);

Type guard

function isRecognisedMedia(bytes) {
  return isType(/^(audio|video)/, bytes);
}

Try / catch

try {
  return playMedia.run(input, [inputFormat]);
} catch (e) {
  if (e.message === "Invalid or unrecognised file type") {
    // prompt user to supply a real audio/video file and the correct format
  }
  throw e;
}

Prevention

When it happens

Trigger: Feeding a non-media file (image, document, archive, text); a media file whose signature CyberChef does not recognise; truncated bytes missing the magic header; choosing the wrong 'Input format' so the bytes are mis-decoded and no signature matches.

Common situations: Passing an image or PDF to Play Media; a Base64 string parsed as Raw (or vice versa) destroying the magic bytes; a corrupted or truncated media file; a media container CyberChef's FileType library does not catalogue.

Related errors


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