jackwener/OpenCLI · error · ArgumentError
type must be one of: line, segment, ray
Error message
type must be one of: line, segment, ray
What it means
ArgumentError thrown by geogebra add-line when the --type value does not map to a supported GeoGebra command. Only line, segment, and ray are accepted; any other string yields no command and triggers this error.
Source
Thrown at clis/geogebra/add-line.js:29
strategy: Strategy.PUBLIC,
browser: true,
navigateBefore: false,
example: 'opencli geogebra add-line --points A,B --type segment',
args: [
{ name: 'points', required: true, help: 'Two point labels separated by comma (e.g. "A,B")' },
{ name: 'type', required: false, choices: ['line', 'segment', 'ray'], default: 'line', help: 'Type: line, segment, or ray (default: line)' },
],
columns: ['label', 'type', 'points'],
func: async (page, kwargs) => {
const [a, b] = normalizeLabelList(kwargs.points, 'points', 2, 2);
const type = kwargs.type || 'line';
const geogebraCmd = {
line: `Line(${a},${b})`,
segment: `Segment(${a},${b})`,
ray: `Ray(${a},${b})`,
}[type];
if (!geogebraCmd) {
throw new ArgumentError('type must be one of: line, segment, ray');
}
await ensureApplet(page);
const result = requireGgbSuccess(await ggbEval(page, geogebraCmd), `Failed to create ${type}: ${geogebraCmd}`);
return [{ label: result.label, type, points: `${a},${b}` }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Use exactly one of: line, segment, ray (lowercase)
- Correct the typo/casing in the script or command
Example fix
// before opencli geogebra add-line --a A --b B --type Line // after opencli geogebra add-line --a A --b B --type line
Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set(['line','segment','ray']);
const t = String(args.type ?? '').trim().toLowerCase();
if (!VALID.has(t)) {
throw new Error(`type must be one of: line, segment, ray (got '${args.type}')`);
} Type guard
function isLineType(v: unknown): v is 'line' | 'segment' | 'ray' {
return v === 'line' || v === 'segment' || v === 'ray';
} Prevention
- Remember values are lowercase and exact
- Whitelist the three accepted values in calling scripts
- Map synonyms (e.g. 'Line'/'straight') to 'line' before invoking
When it happens
Trigger: Passing --type with a misspelled, capitalized, or unsupported value (e.g. 'Line', 'vector', 'lin') at clis/geogebra/add-line.js:29.
Common situations: Case-sensitivity mistakes; assuming other GeoGebra object types are supported; typos in scripts.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Use either --point or --radius, not both
- Provide --radius (number or point label) or --point (point o
- command must contain at least one GeoGebra command
- type must be a GeoGebra object type like point, line, or cir
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d025e6210b661265.
Report an issue: GitHub.