{"record":{"id":"3c856af9354b35eb","repo":"gchq/CyberChef","slug":"invalid-input-format-selected","errorCode":null,"errorMessage":"Invalid input format selected.","messagePattern":"Invalid input format selected\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ParseEthernetFrame.mjs","lineNumber":64,"sourceCode":"        ];\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        const outputFormat = args[1];\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(\"Invalid input format selected.\");\n        }\n\n        const destinationMac = input.slice(0, 6);\n        const sourceMac = input.slice(6, 12);\n\n        let offset = 12;\n        const vlans = [];\n\n        while (offset < input.length) {\n            const ethType = Utils.byteArrayToChars(input.slice(offset, offset+2));\n            offset += 2;\n\n            if (ethType === \"\\x81\\x00\" || ethType === \"\\x88\\xA8\") {\n                // Parse the VLAN tag:\n                // [0000] 0000 0000 0000\n                //  ^^^ PRIO  - Ignored\n                //     ^ DEI  - Ignored\n                //        ^^^^ ^^^^ ^^^^ VLAN ID","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ParseEthernetFrame.mjs#L46-L82","documentation":"The Parse Ethernet Frame operation accepts only 'Hex' or 'Raw' as the input format argument. This defensive else-branch fires for any other value. In the CyberChef UI, the dropdown constrains selection to valid options, so this only occurs with programmatic or recipe-config invocations that pass an unrecognized string.","triggerScenarios":"args[0] is a string other than 'Hex' or 'Raw'. This can happen when a recipe is constructed programmatically with a typo or an unsupported format value, or when a recipe JSON is hand-edited incorrectly.","commonSituations":"Programmatically building a recipe with an invalid format string. Hand-editing a saved recipe JSON and mistyping the format value. Copying a recipe from an older or newer CyberChef version that supports a different option set.","solutions":["Set the 'Input type' argument to either 'Raw' or 'Hex'","If building recipes programmatically, validate the format against the allowed values before execution"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const VALID_FORMATS = [\"Raw\", \"Hex\"];\nif (!VALID_FORMATS.includes(args[0])) {\n  throw new Error(`Input format must be one of: ${VALID_FORMATS.join(\", \")}`);\n}","typeGuard":"function isEthernetInputFormat(v) {\n  return v === \"Raw\" || v === \"Hex\";\n}","tryCatchPattern":null,"preventionTips":["When building recipes programmatically, validate format arguments against the operation's allowed values","Use the operation's constructor args list to determine valid options at runtime"],"tags":["ethernet","network","argument-validation","format"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}