jackwener/OpenCLI · error · ArgumentError
--length must be a positive integer
Error message
--length must be a positive integer
What it means
This ArgumentError comes from `parseSlideDeckLength` and validates the `--length` option of `notebooklm generate-slides`. The value must be a positive integer (or empty/undefined, which defaults to 3); anything else — non-numeric strings, decimals, zero, or negatives — throws.
Source
Thrown at clis/notebooklm/generate-slides.js:52
export function parseSlidesIdFromResult(result, excludedIds = []) {
const excluded = toExcludedUuidSet(excludedIds);
if (typeof result === 'string' && ARTIFACT_UUID_RE.test(result) && !excluded.has(result.toLowerCase())) return result;
const stack = [result];
while (stack.length) {
const node = stack.shift();
if (typeof node === 'string' && ARTIFACT_UUID_RE.test(node) && !excluded.has(node.toLowerCase())) return node;
if (Array.isArray(node)) for (const child of node) stack.push(child);
else if (node && typeof node === 'object') for (const v of Object.values(node)) stack.push(v);
}
return '';
}
export function parseSlideDeckLength(value) {
if (value === undefined || value === '') return 3;
const length = Number(value);
if (!Number.isInteger(length) || length <= 0) {
throw new ArgumentError('--length must be a positive integer');
}
return length;
}
cli({
site: NOTEBOOKLM_SITE,
name: 'generate-slides',
access: 'write',
description: 'Trigger a Slide Deck (AI presentation) generation for a NotebookLM notebook, using all of its sources',
domain: NOTEBOOKLM_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{ name: 'notebook', positional: true, required: true, help: 'Notebook id from `notebooklm list` or full notebook URL' },
{ name: 'length', help: 'Slide deck length: 1=Short, 3=Default (default 3)' },
{ name: 'language', help: 'Language code (default en)' },
{ name: 'execute', type: 'boolean', help: 'Actually trigger remote NotebookLM slide deck generation' },View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a positive integer, e.g. `--length 5`.
- Omit `--length` entirely to use the default of 3.
- Quote the value if your shell mangles it: `--length="5"`.
Example fix
// before opencli notebooklm generate-slides --notebook id --length 2.5 // after opencli notebooklm generate-slides --notebook id --length 5
Defensive patterns
Strategy: validation
Validate before calling
function validateLength(value) {
if (value === undefined || value === '') return 3;
const n = Number(value);
if (!Number.isInteger(n) || n <= 0) throw new Error(`--length must be a positive integer, got ${JSON.stringify(value)}`);
return n;
} Type guard
const isPositiveInt = (v) => Number.isInteger(Number(v)) && Number(v) > 0;
Try / catch
try {
await generateSlides({ notebookId, length });
} catch (e) {
if (String(e.message).includes('--length must be a positive integer')) {
throw new Error(`Bad --length value: ${JSON.stringify(length)}; use a positive integer or omit for default 3`);
}
throw e;
} Prevention
- Always pass --length as a bare positive integer (no units, no decimals).
- Omit --length to use the default of 3.
- Validate CLI args in wrappers/scripts before invoking opencli.
When it happens
Trigger: Passing `--length 0`, `--length -1`, `--length 2.5`, `--length "three"`, or `--length ""`-adjacent garbage like `--length abc` to generate-slides.
Common situations: Copy-pasted flags with units ('10 slides'), locale decimal commas ('2,5'), or shell quoting issues splitting the value.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- bilibili comment ${label} must be a positive integer
- bilibili comment message cannot be empty
- bilibili unfollow target cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/16dff1482900d0d7.
Report an issue: GitHub.