jackwener/OpenCLI · warning · ArgumentError
${label} must contain ${min === max ? min : `${min}-${max}`}
Error message
${label} must contain ${min === max ? min : `${min}-${max}`} comma-separated labels What it means
An ArgumentError from normalizeLabelList: the comma-separated label list had fewer than min or more than max entries. Each entry is then individually validated by normalizeLabel (which reports label[N] on failure). Used e.g. by triangle helpers requiring exactly 3 points.
Source
Thrown at clis/geogebra/utils.js:36
return value;
}
function isPlainObject(value) {
return value && typeof value === 'object' && !Array.isArray(value);
}
export function normalizeLabel(value, label = 'label') {
const normalized = String(value ?? '').trim();
if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(normalized)) {
throw new ArgumentError(`${label} must be an ASCII GeoGebra label like A, B1, or poly_1`);
}
return normalized;
}
export function normalizeLabelList(value, label, min, max = Infinity) {
const parts = String(value ?? '').split(',').map(s => s.trim()).filter(Boolean);
if (parts.length < min || parts.length > max) {
throw new ArgumentError(`${label} must contain ${min === max ? min : `${min}-${max}`} comma-separated labels`);
}
return parts.map((part, idx) => normalizeLabel(part, `${label}[${idx + 1}]`));
}
export function normalizeNumber(value, label, { defaultValue, positive = false } = {}) {
const raw = value == null || value === '' ? defaultValue : value;
const number = Number(raw);
if (!Number.isFinite(number) || (positive && number <= 0)) {
throw new ArgumentError(`${label} must be a ${positive ? 'positive ' : ''}finite number`);
}
return number;
}
export function normalizeCoords(value) {
const parts = String(value ?? '').split(',').map(s => s.trim());
if (parts.length !== 2) {
throw new ArgumentError('coords must be in "x,y" format (e.g. "1,2")');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Supply the required count shown in the message (e.g. min-max range) as comma-separated labels
- Use commas, not spaces: --points A,B,C
- Remove extra labels if over the maximum
- Fix individual label syntax per the follow-up label[N] error if one appears
Example fix
// before opencli geogebra triangle --points A,B // after opencli geogebra triangle --points A,B,C
Defensive patterns
Strategy: validation
Validate before calling
const LABEL_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
const parts = String(points ?? '').split(',').map(s => s.trim()).filter(Boolean);
if (parts.length !== 3) throw new Error(`Expected 3 comma-separated labels, got ${parts.length}`);
if (!parts.every(p => LABEL_RE.test(p))) throw new Error('Each label must match /^[A-Za-z][A-Za-z0-9_]*$/'); Type guard
const isValidLabelList = (v, min, max = Infinity) => {
const parts = String(v ?? '').split(',').map(s => s.trim()).filter(Boolean);
return parts.length >= min && parts.length <= max
&& parts.every(p => /^[A-Za-z][A-Za-z0-9_]*$/.test(p));
}; Try / catch
try {
await run('geogebra', 'triangle', '--points', points);
} catch (err) {
if (/must contain .* comma-separated labels/.test(err.message)) {
points = normalizeToList(points); // pad/trim to required count
return run('geogebra', 'triangle', '--points', points);
}
throw err;
} Prevention
- Always use comma separation, never spaces, for label lists
- Count entries before invoking: triangle helpers typically need exactly 3
- Validate each element against the label regex to avoid a follow-up label[N] error
When it happens
Trigger: `--points A,B` when 3 labels are required (too few); `--points A,B,C,D` when max is 3 (too many); passing a single value where a list is required; extra commas producing empty entries are filtered, so 'A,B,' still counts as 2.
Common situations: Forgetting the third vertex of a triangle; pasting a space-separated list instead of comma-separated; reusing a two-point argument shape for a three-point command.
Related errors
- ${label} must be an ASCII GeoGebra label like A, B1, or poly
- Use either --point or --radius, not both
- Provide --radius (number or point label) or --point (point o
- type must be one of: line, segment, ray
- command must contain at least one GeoGebra command
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/15db56d92e27fede.
Report an issue: GitHub.