{"record":{"id":"6b07914d7d9d06e9","repo":"gchq/CyberChef","slug":"unknown-normalisation-form","errorCode":null,"errorMessage":"Unknown Normalisation Form","messagePattern":"Unknown Normalisation Form","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/NormaliseUnicode.mjs","lineNumber":56,"sourceCode":"    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const [normalForm] = args;\n\n        switch (normalForm) {\n            case \"NFD\":\n                return unorm.nfd(input);\n            case \"NFC\":\n                return unorm.nfc(input);\n            case \"NFKD\":\n                return unorm.nfkd(input);\n            case \"NFKC\":\n                return unorm.nfkc(input);\n            default:\n                throw new OperationError(\"Unknown Normalisation Form\");\n        }\n    }\n\n}\n\nexport default NormaliseUnicode;\n","sourceCodeStart":38,"sourceCodeEnd":63,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/NormaliseUnicode.mjs#L38-L63","documentation":"Thrown by NormaliseUnicode.run when the 'Normal Form' argument (args[0]) is not one of NFD, NFC, NFKD, NFKC — the four Unicode normalisation forms. The switch's default branch catches any other value. Because the argument is an option-type bound to UNICODE_NORMALISATION_FORMS, this is only reachable through API misuse or a tampered recipe.","triggerScenarios":"run(input, args) with args[0] not equal to 'NFD'|'NFC'|'NFKD'|'NFKC'. Reachable by calling run() directly with a custom arg array, loading a hand-edited recipe with an unrecognised form, or a version skew where the option list and the switch disagree.","commonSituations":"Programmatic use of chef.run with a malformed args array; recipe JSON edited manually to an invalid normal form; downstream code computes the form name and passes a typo like 'NFDC'; version mismatch after upgrading where a form constant was renamed.","solutions":["Use one of the four canonical values: 'NFC', 'NFD', 'NFKC', or 'NFKD'.","If building the arg dynamically, validate against UNICODE_NORMALISATION_FORMS before calling.","Re-select the option in the UI to regenerate a valid recipe."],"exampleFix":"// before\nchef.bake(\"Normalise Unicode\", [\"NFDC\"], \"café\");\n// after\nchef.bake(\"Normalise Unicode\", [\"NFC\"], \"café\");","handlingStrategy":"validation","validationCode":"import { UNICODE_NORMALISATION_FORMS } from \"core/lib/ChrEnc.mjs\";\nconst form = args[0];\nif (!UNICODE_NORMALISATION_FORMS.includes(form)) {\n  // pick a valid form: NFC | NFD | NFKC | NFKD\n}","typeGuard":"const isNormalForm = (f) =>\n  [\"NFC\", \"NFD\", \"NFKC\", \"NFKD\"].includes(f);","tryCatchPattern":"try { chef.bake(\"Normalise Unicode\", [form], input); }\ncatch (e) { if (e.message === \"Unknown Normalisation Form\") pickDefaultForm(); else throw e; }","preventionTips":["Always source the form name from the option list.","Validate dynamically-built form names against the four constants.","Re-select the option in the UI to regenerate valid recipe JSON."],"tags":["encoding","unicode","validation","argument-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}