jackwener/OpenCLI · error · ArgumentError
--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into
Error message
--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file. What it means
parseSourceText throws this ArgumentError when the --content string's length exceeds MAX_TEXT_SOURCE_BYTES, the library's cap for inline text sources. The message advises splitting the text into smaller sources or uploading it as a file instead.
Source
Thrown at clis/notebooklm/add-source.js:86
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];
}
function toExcludedUuidSet(excludedIds) {View on GitHub (pinned to 49907e53dc)
Solutions
- Split the text into multiple chunks under the limit and add each as a separate source.
- Write the text to a file and use --file instead (a different, typically larger limit may apply).
- Trim the content to the relevant excerpt before passing it.
- Split on paragraph/heading boundaries with a script to keep chunks semantically coherent.
Example fix
// before
addSource({ content: entireBook });
// after
const chunks = splitByParagraphs(entireBook, MAX_TEXT_SOURCE_BYTES);
for (const c of chunks) addSource({ content: c }); Defensive patterns
Strategy: validation
Validate before calling
if (text.length > MAX_TEXT_SOURCE_BYTES) {
throw new Error(`Content too large inline: ${text.length} > ${MAX_TEXT_SOURCE_BYTES}; split or use --file`);
} Type guard
function fitsInlineText(v, max = MAX_TEXT_SOURCE_BYTES) { return typeof v === 'string' && v.length <= max && v.trim().length > 0; } Try / catch
try {
await addSource({ content: text });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('--content exceeds')) {
for (const chunk of splitByParagraphs(text, MAX_TEXT_SOURCE_BYTES)) {
await addSource({ content: chunk });
}
} else throw e;
} Prevention
- Measure text.length against MAX_TEXT_SOURCE_BYTES before calling.
- Split long documents on paragraph/heading boundaries.
- Prefer --file for large documents instead of inline --content.
- For multi-byte text, remember real byte size can exceed the char count.
When it happens
Trigger: Passing a very long document (book chapter, full transcript, large log dump) as --content whose String length exceeds MAX_TEXT_SOURCE_BYTES; note the check uses text.length (UTF-16 code units) as a byte proxy.
Common situations: Pasting entire meeting transcripts or books; piping a large file's contents into --content instead of using --file; multi-byte content whose real byte size is larger than the char count suggests.
Related errors
- --file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.si
- limit must be <= ${MAX_LIMIT}
- archive snapshots limit must be <= 1000
- coingecko limit must be <= 250 (per_page upper bound)
- --subject must be 200 characters or fewer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/92f80847e859fc82.
Report an issue: GitHub.