gchq/CyberChef · error · OperationError

Unrecognised input format.

Error message

Unrecognised input format.

What it means

Parse UDP only accepts two input encodings: 'Hex' and 'Raw'. The run() method branches on args[0] and throws for any other value. The UI dropdown restricts choices to those two, so in practice this is reachable only through the Node API or a corrupted recipe, not through normal UI interaction.

Source

Thrown at src/core/operations/ParseUDP.mjs:54

                value: ["Hex", "Raw"]
            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {Object}
     */
    run(input, args) {
        const format = args[0];

        if (format === "Hex") {
            input = fromHex(input);
        } else if (format === "Raw") {
            input = Utils.strToArrayBuffer(input);
        } else {
            throw new OperationError("Unrecognised input format.");
        }

        const s = new Stream(new Uint8Array(input));
        if (s.length < 8) {
            throw new OperationError("Need 8 bytes for a UDP Header");
        }

        // Parse Header
        const UDPPacket = {
            "Source port": s.readInt(2),
            "Destination port": s.readInt(2),
            "Length": s.readInt(2),
            "Checksum": "0x" + toHexFast(s.getBytes(2))
        };
        // Parse data if present
        if (s.hasMore()) {
            UDPPacket.Data = "0x" + toHexFast(s.getBytes(UDPPacket.Length - 8));
        }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Pass args[0] as exactly 'Hex' or 'Raw'.
  2. If your data is Base64, decode it to hex/raw first (or use a 'From Base64' op before Parse UDP in the recipe).
  3. When building args programmatically, source the value from the op's declared args list rather than hardcoding.

Example fix

// before: unsupported format
run(buf, ["Base64"]);

// after: convert then parse as hex
run(hexString, ["Hex"]);
Defensive patterns

Strategy: validation

Validate before calling

const format = args[0];
if (format !== "Hex" && format !== "Raw") {
  throw new Error(`Parse UDP format must be 'Hex' or 'Raw', got '${format}'`);
}
return parseUdp.run(input, [format]);

Type guard

function isUdpInputFormat(format) {
  return format === "Hex" || format === "Raw";
}

Try / catch

try {
  return parseUdp.run(input, [format]);
} catch (e) {
  if (e.message === "Unrecognised input format.") args[0] = looksHex(input) ? "Hex" : "Raw";
  throw e;
}

Prevention

When it happens

Trigger: Calling ParseUDP.run(input, [format]) with format not equal to 'Hex' or 'Raw' — e.g. 'Base64', 'Binary', undefined, an empty string, or a typo. Also reachable if a recipe's option arg is migrated/serialized to an unrecognized value.

Common situations: Programmatic callers passing the wrong format identifier; recipe export/import losing the option value; assuming the op accepts Base64 like some other parsers do.

Related errors


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