gchq/CyberChef · error · OperationError
Number of vertical bins must be greater than 0
Error message
Number of vertical bins must be greater than 0
What it means
Thrown by Heatmap chart when the 'Number of vertical bins' argument (vBins, args[2]) is less than or equal to zero. The bin count drives the matrix resolution, so a non-positive value makes the chart unrenderable and is rejected before any data is parsed.
Source
Thrown at src/core/operations/HeatmapChart.mjs:107
/**
* Heatmap chart operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {html}
*/
run(input, args) {
const recordDelimiter = Utils.charRep(args[0]),
fieldDelimiter = Utils.charRep(args[1]),
vBins = args[2],
hBins = args[3],
columnHeadingsAreIncluded = args[4],
drawEdges = args[7],
minColour = args[8],
maxColour = args[9],
dimension = 500;
if (vBins <= 0) throw new OperationError("Number of vertical bins must be greater than 0");
if (hBins <= 0) throw new OperationError("Number of horizontal bins must be greater than 0");
let xLabel = args[5],
yLabel = args[6];
const { headings, values } = getScatterValues(
input,
recordDelimiter,
fieldDelimiter,
columnHeadingsAreIncluded
);
if (headings) {
xLabel = headings.x;
yLabel = headings.y;
}
const document = new nodom.Document();
let svg = document.createElement("svg");View on GitHub (pinned to 4290ea7539)
Solutions
- Set the Number of vertical bins argument to a positive integer (default is 25).
- Choose a bin count appropriate to data density (typically 5-100).
- If building the recipe programmatically, guard args[2] > 0 before passing.
Example fix
// before chart.run(input, ["\n", ",", 0, 25, true]); // after chart.run(input, ["\n", ",", 25, 25, true]);
Defensive patterns
Strategy: validation
Validate before calling
function assertVerticalBins(vBins) {
if (!Number.isFinite(vBins) || vBins <= 0 || !Number.isInteger(vBins)) {
throw new RangeError(`Vertical bins must be a positive integer, got ${vBins}`);
}
} Type guard
function isValidVerticalBins(v) {
return Number.isInteger(v) && v > 0;
} Try / catch
try {
html = heatmap.run(input, args);
} catch (e) {
if (e instanceof OperationError && /vertical bins/i.test(e.message)) {
args[2] = 25; // fall back to default
html = heatmap.run(input, args);
} else throw e;
} Prevention
- Default the vertical bins field to 25 in generated recipes.
- Coerce empty/missing numeric args to the default, not 0.
- Validate args[2] is a positive integer before invoking.
When it happens
Trigger: Setting the vertical bins argument to 0 or a negative number; a recipe/JSON config that defaults an unset numeric field to 0; programmatic invocation passing args[2] <= 0.
Common situations: Defaulting a numeric arg to 0 in a generated recipe; user clearing the field and the UI coercing empty to 0; copying a recipe that used a placeholder.
Related errors
- Number of horizontal bins must be greater than 0
- Invalid block cipher mode: ${mode}
- Invalid ciphertext length: ${originalLength} bytes. Must be
- No padding requested but input is not a ${blockSize}-byte mu
- Unknown padding type: ${padding}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/6f076fab331b9437.
Report an issue: GitHub.