{"record":{"id":"b6b441e3f0c0795f","repo":"gchq/CyberChef","slug":"unrecognised-input-format-b6b441","errorCode":null,"errorMessage":"Unrecognised input format.","messagePattern":"Unrecognised input format\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ParseUDP.mjs","lineNumber":54,"sourceCode":"                value: [\"Hex\", \"Raw\"]\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {Object}\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 < 8) {\n            throw new OperationError(\"Need 8 bytes for a UDP Header\");\n        }\n\n        // Parse Header\n        const UDPPacket = {\n            \"Source port\": s.readInt(2),\n            \"Destination port\": s.readInt(2),\n            \"Length\": s.readInt(2),\n            \"Checksum\": \"0x\" + toHexFast(s.getBytes(2))\n        };\n        // Parse data if present\n        if (s.hasMore()) {\n            UDPPacket.Data = \"0x\" + toHexFast(s.getBytes(UDPPacket.Length - 8));\n        }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ParseUDP.mjs#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"Programmatic callers passing the wrong format identifier; recipe export/import losing the option value; assuming the op accepts Base64 like some other parsers do.","solutions":["Pass args[0] as exactly 'Hex' or 'Raw'.","If your data is Base64, decode it to hex/raw first (or use a 'From Base64' op before Parse UDP in the recipe).","When building args programmatically, source the value from the op's declared args list rather than hardcoding."],"exampleFix":"// before: unsupported format\nrun(buf, [\"Base64\"]);\n\n// after: convert then parse as hex\nrun(hexString, [\"Hex\"]);","handlingStrategy":"validation","validationCode":"const format = args[0];\nif (format !== \"Hex\" && format !== \"Raw\") {\n  throw new Error(`Parse UDP format must be 'Hex' or 'Raw', got '${format}'`);\n}\nreturn parseUdp.run(input, [format]);","typeGuard":"function isUdpInputFormat(format) {\n  return format === \"Hex\" || format === \"Raw\";\n}","tryCatchPattern":"try {\n  return parseUdp.run(input, [format]);\n} catch (e) {\n  if (e.message === \"Unrecognised input format.\") args[0] = looksHex(input) ? \"Hex\" : \"Raw\";\n  throw e;\n}","preventionTips":["Restrict the format arg to the declared options.","For Base64 data, decode to hex first rather than inventing a format value.","Build args from the op's metadata instead of hardcoding."],"tags":["networking","udp","input-validation","config"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}