gchq/CyberChef · error · OperationError

Unknown Normalisation Form

Error message

Unknown Normalisation Form

What it means

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.

Source

Thrown at src/core/operations/NormaliseUnicode.mjs:56

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {string}
     */
    run(input, args) {
        const [normalForm] = args;

        switch (normalForm) {
            case "NFD":
                return unorm.nfd(input);
            case "NFC":
                return unorm.nfc(input);
            case "NFKD":
                return unorm.nfkd(input);
            case "NFKC":
                return unorm.nfkc(input);
            default:
                throw new OperationError("Unknown Normalisation Form");
        }
    }

}

export default NormaliseUnicode;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Use one of the four canonical values: 'NFC', 'NFD', 'NFKC', or 'NFKD'.
  2. If building the arg dynamically, validate against UNICODE_NORMALISATION_FORMS before calling.
  3. Re-select the option in the UI to regenerate a valid recipe.

Example fix

// before
chef.bake("Normalise Unicode", ["NFDC"], "café");
// after
chef.bake("Normalise Unicode", ["NFC"], "café");
Defensive patterns

Strategy: validation

Validate before calling

import { UNICODE_NORMALISATION_FORMS } from "core/lib/ChrEnc.mjs";
const form = args[0];
if (!UNICODE_NORMALISATION_FORMS.includes(form)) {
  // pick a valid form: NFC | NFD | NFKC | NFKD
}

Type guard

const isNormalForm = (f) =>
  ["NFC", "NFD", "NFKC", "NFKD"].includes(f);

Try / catch

try { chef.bake("Normalise Unicode", [form], input); }
catch (e) { if (e.message === "Unknown Normalisation Form") pickDefaultForm(); else throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/6b07914d7d9d06e9. Report an issue: GitHub.