{"record":{"id":"b0b13e474373d46b","repo":"gchq/CyberChef","slug":"unrecognised-unit-b0b13e","errorCode":null,"errorMessage":"Unrecognised unit","messagePattern":"Unrecognised unit","errorType":"validation","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs","lineNumber":82,"sourceCode":"\n        if (format.startsWith(\"Hex\")) {\n            input = new BigNumber(input, 16);\n        } else {\n            input = new BigNumber(input);\n        }\n\n        input = input.minus(new BigNumber(\"116444736000000000\"));\n\n        if (units === \"Seconds (s)\") {\n            input = input.dividedBy(new BigNumber(\"10000000\"));\n        } else if (units === \"Milliseconds (ms)\") {\n            input = input.dividedBy(new BigNumber(\"10000\"));\n        } else if (units === \"Microseconds (μs)\") {\n            input = input.dividedBy(new BigNumber(\"10\"));\n        } else if (units === \"Nanoseconds (ns)\") {\n            input = input.multipliedBy(new BigNumber(\"100\"));\n        } else {\n            throw new OperationError(\"Unrecognised unit\");\n        }\n\n        return input.toFixed();\n    }\n\n}\n\nexport default WindowsFiletimeToUNIXTimestamp;\n","sourceCodeStart":64,"sourceCodeEnd":91,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs#L64-L91","documentation":"Thrown by WindowsFiletimeToUNIXTimestamp.run after subtracting the 1601→1970 epoch offset (116444736000000000). The operation must divide/multiply the resulting 100-nanosecond count into the requested precision, so it only recognises four exact unit strings: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', 'Nanoseconds (ns)'. Any other value for args[0] ('Output units') falls into the trailing else and aborts before producing a timestamp.","triggerScenarios":"The 'Output units' argument is set to a string not in the option list. In the UI this is prevented by a dropdown, so the error only appears when a recipe/config is built programmatically (Node API chef.bake, imported .chr recipe JSON, or a hand-edited opList) with a typo'd or localised unit string.","commonSituations":"Copying a recipe JSON between CyberChef versions or forks where the unit labels differ; feeding an opList built by another tool; passing a raw value like 'ms' or 'Seconds' instead of the full canonical 'Milliseconds (ms)' / 'Seconds (s)'.","solutions":["Set args[0] to one of the four exact canonical strings the constructor lists: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', 'Nanoseconds (ns) — including the parenthesised suffix and, for microseconds, the μ character.","If you imported a recipe/config, re-export it from the current CyberChef build so the unit label matches the installed version.","Avoid mutating the units argument manually; build the opList from the operation's own args metadata rather than hard-coding the string."],"exampleFix":"// before\nchef.bake(input, [{op:\"Windows Filetime to UNIX Timestamp\", args:[\"ms\",\"Decimal\"]}]);\n// after\nchef.bake(input, [{op:\"Windows Filetime to UNIX Timestamp\", args:[\"Milliseconds (ms)\",\"Decimal\"]}]);","handlingStrategy":"validation","validationCode":"const VALID_UNITS = [\"Seconds (s)\",\"Milliseconds (ms)\",\"Microseconds (μs)\",\"Nanoseconds (ns)\"];\nfunction buildFiletimeRecipe(units, format=\"Decimal\") {\n  if (!VALID_UNITS.includes(units)) throw new Error(`units must be one of ${VALID_UNITS.join(\", \")}`);\n  return [{op:\"Windows Filetime to UNIX Timestamp\", args:[units, format]}];\n}","typeGuard":"const isFiletimeUnit = (u) => [\"Seconds (s)\",\"Milliseconds (ms)\",\"Microseconds (μs)\",\"Nanoseconds (ns)\"].includes(u);","tryCatchPattern":"try { result = chef.bake(input, recipe); } catch (e) { if (/Unrecognised unit/.test(e.message)) { /* fix units arg */ } else throw e; }","preventionTips":["Always source the units string from the operation's declared args value list, not a hard-coded literal.","Validate the opList shape before calling chef.bake.","When importing recipes, re-export them from the target build so labels match."],"tags":["windows-filetime","unix-timestamp","operation-args","config-mismatch"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}