gchq/CyberChef · error · OperationError
Unknown granularity value: ${granularity}
Error message
Unknown granularity value: ${granularity} What it means
Thrown by GetTime when the granularity argument is not one of the four recognized units: Nanoseconds (ns), Microseconds (μs), Milliseconds (ms), or Seconds (s). The switch selects the multiplier to convert the current epoch-millis time; an unknown unit is rejected rather than defaulted.
Source
Thrown at src/core/operations/GetTime.mjs:57
* @param {string} input
* @param {Object[]} args
* @returns {number}
*/
run(input, args) {
const nowMs = (performance.timeOrigin + performance.now()),
granularity = args[0];
switch (granularity) {
case "Nanoseconds (ns)":
return Math.round(nowMs * 1000 * 1000);
case "Microseconds (μs)":
return Math.round(nowMs * 1000);
case "Milliseconds (ms)":
return Math.round(nowMs);
case "Seconds (s)":
return Math.round(nowMs / 1000);
default:
throw new OperationError("Unknown granularity value: " + granularity);
}
}
}
export default GetTime;
View on GitHub (pinned to 4290ea7539)
Solutions
- Set granularity to one of: 'Nanoseconds (ns)', 'Microseconds (μs)', 'Milliseconds (ms)', 'Seconds (s)'.
- If building recipes in code, validate granularity against the exact supported strings.
Example fix
// before args = ["Minutes"]; // after args = ["Milliseconds (ms)"];
Defensive patterns
Strategy: type-guard
Validate before calling
const VALID_GRANULARITIES = [
"Nanoseconds (ns)",
"Microseconds (\u03bcs)",
"Milliseconds (ms)",
"Seconds (s)"
];
if (!VALID_GRANULARITIES.includes(granularity)) {
// reject before invoking
} Type guard
function isTimeGranularity(g) {
return [
"Nanoseconds (ns)",
"Microseconds (\u03bcs)",
"Milliseconds (ms)",
"Seconds (s)"
].includes(g);
} Prevention
- Restrict the granularity control to the four known labels (note the μ character in Microseconds).
- Match the exact label strings, including units in parentheses.
When it happens
Trigger: Passing a granularity string outside the four recognized labels, including misspellings, alternate casing, or values like 'Minutes'/'Hours' which are not supported.
Common situations: Recipe built in code with an unsupported granularity, or a localized label mismatch from the UI.
Related errors
- Unsupported Mode: (${mode})
- Invalid length type
- Invalid UUID version
- Invalid secret. The input must be a valid base32 string (cha
- Length must be greater than 0
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/972735dbe83a9e6b.
Report an issue: GitHub.