{"record":{"id":"4bd43c0daec01352","repo":"gchq/CyberChef","slug":"unrecognised-input-format-4bd43c","errorCode":null,"errorMessage":"Unrecognised input format.","messagePattern":"Unrecognised input format\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ParseTCP.mjs","lineNumber":56,"sourceCode":"                value: [\"Hex\", \"Raw\"]\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {html}\n     */\n    run(input, args) {\n        const format = args[0];\n\n        if (format === \"Hex\") {\n            input = fromHex(input);\n        } else if (format === \"Raw\") {\n            input = Utils.strToArrayBuffer(input);\n        } else {\n            throw new OperationError(\"Unrecognised input format.\");\n        }\n\n        const s = new Stream(new Uint8Array(input));\n        if (s.length < 20) {\n            throw new OperationError(\"Need at least 20 bytes for a TCP Header\");\n        }\n\n        // Parse Header\n        const TCPPacket = {\n            \"Source port\": s.readInt(2),\n            \"Destination port\": s.readInt(2),\n            \"Sequence number\": bytesToLargeNumber(s.getBytes(4)),\n            \"Acknowledgement number\": s.readInt(4),\n            \"Data offset\": s.readBits(4),\n            \"Flags\": {\n                \"Reserved\": toBinary(s.readBits(3), \"\", 3),\n                \"NS\": s.readBits(1),\n                \"CWR\": s.readBits(1),","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ParseTCP.mjs#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the 'Input format' argument to either 'Hex' or 'Raw'","Validate format values programmatically before recipe execution"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const VALID_FORMATS = [\"Hex\", \"Raw\"];\nif (!VALID_FORMATS.includes(args[0])) {\n  throw new Error(`Input format must be one of: ${VALID_FORMATS.join(\", \")}`);\n}","typeGuard":"function isTcpInputFormat(v) {\n  return v === \"Hex\" || v === \"Raw\";\n}","tryCatchPattern":null,"preventionTips":["Validate format arguments programmatically against the allowed values before recipe execution"],"tags":["tcp","network","argument-validation","format"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}