{"record":{"id":"09da07814a45d1c9","repo":"gchq/CyberChef","slug":"unrecognised-input-format","errorCode":null,"errorMessage":"Unrecognised input format.","messagePattern":"Unrecognised input format\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ParseIPv4Header.mjs","lineNumber":62,"sourceCode":"    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {html}\n     */\n    run(input, args) {\n        const format = args[0];\n        const outputFormat = args[1];\n\n        let output;\n\n        if (format === \"Hex\") {\n            input = fromHex(input);\n        } else if (format === \"Raw\") {\n            input = new Uint8Array(Utils.strToArrayBuffer(input));\n        } else {\n            throw new OperationError(\"Unrecognised input format.\");\n        }\n\n        let ihl = input[0] & 0x0f;\n        const dscp = (input[1] >>> 2) & 0x3f,\n            ecn = input[1] & 0x03,\n            length = input[2] << 8 | input[3],\n            identification = input[4] << 8 | input[5],\n            flags = (input[6] >>> 5) & 0x07,\n            fragOffset = (input[6] & 0x1f) << 8 | input[7],\n            ttl = input[8],\n            protocol = input[9],\n            checksum = input[10] << 8 | input[11],\n            srcIP = input[12] << 24 | input[13] << 16 | input[14] << 8 | input[15],\n            dstIP = input[16] << 24 | input[17] << 16 | input[18] << 8 | input[19],\n            checksumHeader = [...input.slice(0, 10), 0, 0, ...input.slice(12, 20)];\n        let version = (input[0] >>> 4) & 0x0f,\n            options = [];\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ParseIPv4Header.mjs#L44-L80","documentation":"The Parse IPv4 Header operation accepts only 'Hex' or 'Raw' as the input format argument. This defensive else-branch fires for any other value. In the UI, the dropdown prevents invalid selection; this only triggers 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.","commonSituations":"Programmatically building a recipe with a typo in the format argument. Recipe JSON edited by hand with an incorrect value. Recipe copied between CyberChef versions with different option sets.","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 isIPv4InputFormat(v) {\n  return v === \"Hex\" || v === \"Raw\";\n}","tryCatchPattern":null,"preventionTips":["Validate format arguments programmatically against the allowed values before recipe execution"],"tags":["ipv4","network","argument-validation","format"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}