gchq/CyberChef · error · OperationError

Unrecognised input format.

Error message

Unrecognised input format.

What it means

The Parse TCP operation accepts only 'Hex' or 'Raw' as the input format argument. This defensive else-branch fires for any other value. The UI dropdown constrains selection, so this triggers only with programmatic or hand-edited recipe configurations.

Source

Thrown at src/core/operations/ParseTCP.mjs:56

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

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {html}
     */
    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 < 20) {
            throw new OperationError("Need at least 20 bytes for a TCP Header");
        }

        // Parse Header
        const TCPPacket = {
            "Source port": s.readInt(2),
            "Destination port": s.readInt(2),
            "Sequence number": bytesToLargeNumber(s.getBytes(4)),
            "Acknowledgement number": s.readInt(4),
            "Data offset": s.readBits(4),
            "Flags": {
                "Reserved": toBinary(s.readBits(3), "", 3),
                "NS": s.readBits(1),
                "CWR": s.readBits(1),

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set the 'Input format' argument to either 'Hex' or 'Raw'
  2. Validate format values programmatically before recipe execution
Defensive patterns

Strategy: validation

Validate before calling

const VALID_FORMATS = ["Hex", "Raw"];
if (!VALID_FORMATS.includes(args[0])) {
  throw new Error(`Input format must be one of: ${VALID_FORMATS.join(", ")}`);
}

Type guard

function isTcpInputFormat(v) {
  return v === "Hex" || v === "Raw";
}

Prevention

When it happens

Trigger: args[0] is a string other than 'Hex' or 'Raw'. Occurs when constructing recipes programmatically with an invalid format value, or hand-editing recipe JSON with a typo.

Common situations: Programmatically building a recipe with a misspelled format argument. Recipe JSON edited by hand with an incorrect value. Recipe ported from a different CyberChef version.

Related errors


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