gchq/CyberChef · error · OperationError

Unrecognised unit

Error message

Unrecognised unit

What it means

Thrown by 'UNIX Timestamp to Windows Filetime' when the units argument matches none of 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (us)', or 'Nanoseconds (ns)'. The units string is compared exactly; any other value falls through to the else branch.

Source

Thrown at src/core/operations/UNIXTimestampToWindowsFiletime.mjs:63

     * @returns {string}
     */
    run(input, args) {
        const [units, format] = args;

        if (!input) return "";

        input = new BigNumber(input);

        if (units === "Seconds (s)") {
            input = input.multipliedBy(new BigNumber("10000000"));
        } else if (units === "Milliseconds (ms)") {
            input = input.multipliedBy(new BigNumber("10000"));
        } else if (units === "Microseconds (μs)") {
            input = input.multipliedBy(new BigNumber("10"));
        } else if (units === "Nanoseconds (ns)") {
            input = input.dividedBy(new BigNumber("100"));
        } else {
            throw new OperationError("Unrecognised unit");
        }

        input = input.plus(new BigNumber("116444736000000000"));

        let result;
        if (format.startsWith("Hex")) {
            result = input.toString(16);
        } else {
            result = input.toFixed();
        }

        if (format === "Hex (little endian)") {
            // Swap endianness
            let flipped = "";
            for (let i = result.length - 2; i >= 0; i -= 2) {
                flipped += result.charAt(i);
                flipped += result.charAt(i + 1);
            }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Use one of the exact option strings: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', or 'Nanoseconds (ns)'.
  2. Pull the allowed values from the operation's args definition instead of hardcoding.
  3. Watch for look-alike micro signs (μ vs µ) when copy-pasting.
Defensive patterns

Strategy: validation

Validate before calling

const UNITS = ["Seconds (s)", "Milliseconds (ms)", "Microseconds (\u03bcs)", "Nanoseconds (ns)"];
if (!UNITS.includes(units)) {
  throw new Error(`Unrecognised unit '${units}'`);
}

Type guard

function isValidFiletimeUnit(u) { return ["Seconds (s)","Milliseconds (ms)","Microseconds (\u03bcs)","Nanoseconds (ns)"].includes(u); }

Prevention

When it happens

Trigger: Passing a units value that is not one of the four exact option strings, e.g. a lowercased 'seconds (s)', 'Microseconds (µs)' with the wrong micro sign, or undefined. Reachable via the Node API or a hand-edited recipe since the UI restricts to the dropdown.

Common situations: Programmatically building a recipe with a units string copied from docs that uses a different micro-character (μ U+03BC vs µ U+00B5), or localised/case-altered labels.

Related errors


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