jackwener/OpenCLI · error · ArgumentError

--content is required

Error message

--content is required

What it means

parseNoteContent validates the --content option for write-note: it stringifies the value and throws ArgumentError if the result is empty. Note content is mandatory, so the command fails fast before touching the browser.

Source

Thrown at clis/notebooklm/write-note.js:24

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]];
}

export function buildMutateNoteArgs(projectId, noteId, content, title) {
    return [projectId, noteId, [[[content, title, [], 0]]], [2]];
}

function toExcludedUuidSet(excludedIds) {
    return new Set(excludedIds.map((id) => String(id ?? '').toLowerCase()).filter(Boolean));
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide non-empty content via --content "..." or by piping text into the command.
  2. Verify the file you read content from actually exists and is non-empty.
  3. Check pipelines: ensure the upstream command emits data (e.g. cat file | write-note ...).
  4. In scripts, assert content length > 0 before invoking write-note.

Example fix

// before
const content = fs.readFileSync(path, 'utf8');
await writeNote({ title, content });

// after
const content = fs.readFileSync(path, 'utf8');
if (!content.trim()) throw new Error(`Content file ${path} is empty`);
await writeNote({ title, content });
Defensive patterns

Strategy: validation

Validate before calling

const content = String(rawContent ?? '');
if (!content) throw new Error('--content is required (pass text via --content or stdin)');

Type guard

const hasContent = (v) => typeof v === 'string' && v.length > 0;

Try / catch

try {
  await writeNote({ title, content });
} catch (e) {
  if (String(e.message).includes('--content is required')) {
    console.error('Usage: write-note --title "T" --content "text" (or pipe content via stdin).');
    process.exit(2);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling write-note without --content, with an empty string, or with a value that stringifies to empty (undefined/null); also when a file/stdin read that was supposed to feed content returned nothing.

Common situations: Forgetting the flag, a file path typo making a read return empty, an empty stdin pipe in a pipeline, or shell variable expansion of an unset variable.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/dda29902b362d2ee. Report an issue: GitHub.