jackwener/OpenCLI · error · ArgumentError

--content must not be empty

Error message

--content must not be empty

What it means

parseSourceText throws this ArgumentError when --content is provided but is whitespace-only after conversion to a string. Since the value is not undefined/null (which would mean 'no text source'), an empty string is treated as a user mistake rather than an omitted option, so it fails fast before any upload is attempted.

Source

Thrown at clis/notebooklm/add-source.js:84

export function parseSourceUrl(value) {
    const url = String(value ?? '').trim();
    if (!url) return '';
    let parsed;
    try {
        parsed = new URL(url);
    } catch {
        throw new ArgumentError(`Invalid source URL: "${url}"`, 'URL must be a valid http:// or https:// URL.');
    }
    if ((parsed.protocol !== 'http:' && parsed.protocol !== 'https:') || !parsed.hostname) {
        throw new ArgumentError(`Invalid source URL: "${url}"`, 'URL must start with http:// or https://.');
    }
    return parsed.toString();
}

export function parseSourceText(value) {
    if (value === undefined || value === null) return null;
    const text = String(value);
    if (!text.trim()) throw new ArgumentError('--content must not be empty');
    if (text.length > MAX_TEXT_SOURCE_BYTES) {
        throw new ArgumentError(`--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file.`);
    }
    return text;
}

export function parseSourceTitle(value, fallback) {
    const title = String(value ?? '').trim();
    return title || fallback;
}

export function buildAddSourceFromUrlArgs(projectId, url) {
    return [[[null, null, [url]]], projectId];
}

export function buildAddSourceFromTextArgs(projectId, title, content) {
    return [[[null, [title, content], null, 2]], projectId];
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide non-empty text with --content.
  2. If you meant to omit the text source entirely, drop the --content flag instead of passing an empty value.
  3. Fix the upstream step that produced empty text (check the file/stdout it reads from).
  4. Guard in your script: only pass --content when text.trim() is non-empty.

Example fix

// before
addSource({ content: notes.trim() }); // notes was empty
// after
if (notes.trim()) addSource({ content: notes });
else addSource({ url: fallbackUrl });
Defensive patterns

Strategy: validation

Validate before calling

const text = typeof content === 'string' ? content : '';
if (text !== '' && !text.trim()) throw new Error('Refusing to pass empty --content; omit the flag or supply real text');

Type guard

function isNonEmptyText(v) { return typeof v === 'string' && v.trim().length > 0; }

Try / catch

try {
  await addSource({ content });
} catch (e) {
  if (e instanceof ArgumentError && e.message === '--content must not be empty') {
    console.error('The upstream text source produced empty output; check the extraction step.');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling add-source with --content '' or --content ' '; a variable holding the text being empty because an earlier step produced no output; passing --content without a value so the shell supplies an empty string.

Common situations: Scripting the CLI where a text-extraction step returned an empty file/stdout; quoting mistakes producing an empty argument; CI pipelines where an env var like $NOTES was unset, expanding to nothing.

Related errors


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