gchq/CyberChef · error · OperationError
Number of horizontal bins must be greater than 0
Error message
Number of horizontal bins must be greater than 0
What it means
Sibling guard to 410, thrown by Heatmap chart when the 'Number of horizontal bins' argument (hBins, args[3]) is <= 0. Checked immediately after the vertical bins guard. Same rationale: a non-positive bin count cannot produce a matrix.
Source
Thrown at src/core/operations/HeatmapChart.mjs:108
/**
* 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");
svg = d3.select(svg)View on GitHub (pinned to 4290ea7539)
Solutions
- Set the Number of horizontal bins argument to a positive integer (default is 25).
- Match the bin count to the X-axis spread of your data.
- Validate args[3] > 0 in code before invoking.
Example fix
// before chart.run(input, ["\n", ",", 25, 0, true]); // after chart.run(input, ["\n", ",", 25, 25, true]);
Defensive patterns
Strategy: validation
Validate before calling
function assertHorizontalBins(hBins) {
if (!Number.isFinite(hBins) || hBins <= 0 || !Number.isInteger(hBins)) {
throw new RangeError(`Horizontal bins must be a positive integer, got ${hBins}`);
}
} Type guard
function isValidHorizontalBins(v) {
return Number.isInteger(v) && v > 0;
} Try / catch
try {
html = heatmap.run(input, args);
} catch (e) {
if (e instanceof OperationError && /horizontal bins/i.test(e.message)) {
args[3] = 25;
html = heatmap.run(input, args);
} else throw e;
} Prevention
- Default the horizontal bins field to 25 in generated recipes.
- Never let a numeric arg default to 0.
- Validate args[3] is a positive integer before invoking.
When it happens
Trigger: Setting the horizontal bins argument to 0 or negative; programmatic args[3] <= 0; a generated recipe leaving the field unset/zeroed.
Common situations: Same as 410: cleared field coerced to 0, placeholder in config, copy-paste of a partial recipe.
Related errors
- Number of vertical 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/b5ded2d4b49f3f66.
Report an issue: GitHub.