{"record":{"id":"92f80847e859fc82","repo":"jackwener/OpenCLI","slug":"content-exceeds-max-text-source-bytes-bytes","errorCode":null,"errorMessage":"--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file.","messagePattern":"--content exceeds (.+?) bytes; split into smaller sources or upload as a file\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/add-source.js","lineNumber":86,"sourceCode":"    if (!url) return '';\n    let parsed;\n    try {\n        parsed = new URL(url);\n    } catch {\n        throw new ArgumentError(`Invalid source URL: \"${url}\"`, 'URL must be a valid http:// or https:// URL.');\n    }\n    if ((parsed.protocol !== 'http:' && parsed.protocol !== 'https:') || !parsed.hostname) {\n        throw new ArgumentError(`Invalid source URL: \"${url}\"`, 'URL must start with http:// or https://.');\n    }\n    return parsed.toString();\n}\n\nexport function parseSourceText(value) {\n    if (value === undefined || value === null) return null;\n    const text = String(value);\n    if (!text.trim()) throw new ArgumentError('--content must not be empty');\n    if (text.length > MAX_TEXT_SOURCE_BYTES) {\n        throw new ArgumentError(`--content exceeds ${MAX_TEXT_SOURCE_BYTES} bytes; split into smaller sources or upload as a file.`);\n    }\n    return text;\n}\n\nexport function parseSourceTitle(value, fallback) {\n    const title = String(value ?? '').trim();\n    return title || fallback;\n}\n\nexport function buildAddSourceFromUrlArgs(projectId, url) {\n    return [[[null, null, [url]]], projectId];\n}\n\nexport function buildAddSourceFromTextArgs(projectId, title, content) {\n    return [[[null, [title, content], null, 2]], projectId];\n}\n\nfunction toExcludedUuidSet(excludedIds) {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/add-source.js#L68-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\naddSource({ content: entireBook });\n// after\nconst chunks = splitByParagraphs(entireBook, MAX_TEXT_SOURCE_BYTES);\nfor (const c of chunks) addSource({ content: c });","handlingStrategy":"validation","validationCode":"if (text.length > MAX_TEXT_SOURCE_BYTES) {\n  throw new Error(`Content too large inline: ${text.length} > ${MAX_TEXT_SOURCE_BYTES}; split or use --file`);\n}","typeGuard":"function fitsInlineText(v, max = MAX_TEXT_SOURCE_BYTES) { return typeof v === 'string' && v.length <= max && v.trim().length > 0; }","tryCatchPattern":"try {\n  await addSource({ content: text });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--content exceeds')) {\n    for (const chunk of splitByParagraphs(text, MAX_TEXT_SOURCE_BYTES)) {\n      await addSource({ content: chunk });\n    }\n  } else throw e;\n}","preventionTips":["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."],"tags":["content-size","argument-validation","notebooklm","limits"],"backgroundTag":"payload-too-large","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}