jackwener/OpenCLI · error · ArgumentError
--title is required
Error message
--title is required
What it means
parseNoteTitle validates the --title option for the write-note command: it stringifies and trims the value, and throws ArgumentError when nothing remains. This guarantees every note created in NotebookLM has a non-empty title before any browser automation runs.
Source
Thrown at clis/notebooklm/write-note.js:15
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
import { NOTEBOOKLM_DOMAIN, NOTEBOOKLM_SITE } from './shared.js';
import { callNotebooklmRpc } from './rpc.js';
import { buildNotebooklmNotebookUrl, ensureNotebooklmHome, parseNotebooklmNotebookTarget, requireNotebooklmExecute, requireNotebooklmSession } from './utils.js';
const NOTEBOOKLM_CREATE_NOTE_RPC_ID = 'CYK0Xb';
const NOTEBOOKLM_MUTATE_NOTE_RPC_ID = 'cYAfTb';
const MAX_TITLE_LEN = 200;
const MAX_CONTENT_LEN = 1_000_000;
const NOTE_UUID_RE = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
export function parseNoteTitle(value) {
const title = String(value ?? '').trim();
if (!title) throw new ArgumentError('--title is required');
if (title.length > MAX_TITLE_LEN) {
throw new ArgumentError(`--title must be at most ${MAX_TITLE_LEN} characters (got ${title.length})`);
}
return title;
}
export function parseNoteContent(value) {
const content = String(value ?? '');
if (!content) throw new ArgumentError('--content is required');
if (content.length > MAX_CONTENT_LEN) {
throw new ArgumentError(`--content exceeds ${MAX_CONTENT_LEN} characters; split into smaller notes.`);
}
return content;
}
export function buildCreateNoteShellArgs(projectId) {
return [projectId, '', [1], null, 'New Note', null, [2]];
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty --title value, e.g. --title "Meeting notes".
- Quote titles containing spaces so the shell does not split or drop them.
- In scripts, check the title variable is non-empty before invoking write-note.
- Fix the upstream command/pipeline that produced an empty title.
Example fix
// before
await writeNote({ title: process.env.NOTE_TITLE, content });
// after
const title = (process.env.NOTE_TITLE || '').trim();
if (!title) throw new Error('NOTE_TITLE must be set to a non-empty value');
await writeNote({ title, content }); Defensive patterns
Strategy: validation
Validate before calling
const title = String(rawTitle ?? '').trim();
if (!title) throw new Error('--title is required'); Type guard
const hasTitle = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
await writeNote({ title, content });
} catch (e) {
if (String(e.message).includes('--title is required')) {
console.error('Usage: write-note --title "My note" --content "..."');
process.exit(2);
}
throw e;
} Prevention
- Always quote --title values in shell scripts.
- Check upstream variables for emptiness before invoking write-note.
- Default missing titles to a timestamped placeholder in wrappers.
- Validate required CLI flags at script start.
When it happens
Trigger: Calling write-note without --title, with --title "" or whitespace-only, or passing undefined/null for the title parameter.
Common situations: Forgetting the flag on the command line, a script variable being empty because an upstream command produced no output, or quoting mistakes yielding an empty argument.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --content is required
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cd410758680ad53f.
Report an issue: GitHub.