{"record":{"id":"b5960f8b0ebf5234","repo":"jackwener/OpenCLI","slug":"file-exceeds-max-file-source-bytes-bytes-got","errorCode":null,"errorMessage":"--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.size}); use a smaller file or upload via the NotebookLM UI for now.","messagePattern":"--file exceeds (.+?) bytes \\(got (.+?)\\); use a smaller file or upload via the NotebookLM UI for now\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/add-source.js","lineNumber":51,"sourceCode":"export function inferMimeType(filename, override) {\n    if (override) return String(override);\n    const ext = path.extname(filename).toLowerCase();\n    return MIME_BY_EXT[ext] || 'application/octet-stream';\n}\n\nexport function readFileForUpload(filePath) {\n    const abs = path.resolve(filePath);\n    let stat;\n    try {\n        stat = fs.statSync(abs);\n    } catch {\n        throw new ArgumentError(`--file path does not exist: ${filePath}`);\n    }\n    if (!stat.isFile()) {\n        throw new ArgumentError(`--file path is not a regular file: ${filePath}`);\n    }\n    if (stat.size > MAX_FILE_SOURCE_BYTES) {\n        throw new ArgumentError(`--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.size}); use a smaller file or upload via the NotebookLM UI for now.`);\n    }\n    const buf = fs.readFileSync(abs);\n    return { base64: buf.toString('base64'), filename: path.basename(abs), size: stat.size };\n}\n\nexport function buildRegisterFileSourceArgs(projectId, filename) {\n    return [\n        [[filename]],\n        projectId,\n        [2],\n        [1, null, null, null, null, null, null, null, null, null, [1]],\n    ];\n}\n\nexport function parseSourceUrl(value) {\n    const url = String(value ?? '').trim();\n    if (!url) return '';\n    let parsed;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/add-source.js#L33-L69","documentation":"readFileForUpload throws this ArgumentError when the file at --file is a regular file but its size (stat.size) exceeds MAX_FILE_SOURCE_BYTES, the library's cap for file-based NotebookLM sources. The message includes the actual byte size and suggests using a smaller file or the NotebookLM UI.","triggerScenarios":"Uploading a large PDF, video, or dataset via --file whose byte length exceeds MAX_FILE_SOURCE_BYTES; the check runs after the file-exists and regular-file checks and before readFileSync.","commonSituations":"Attaching a large scanned PDF or recorded meeting export; batch-generated reports exceeding the cap; not realizing the CLI enforces a smaller limit than the NotebookLM web UI.","solutions":["Compress or downscale the file (PDF compression, lower-resolution export) so it fits under MAX_FILE_SOURCE_BYTES.","Split the content into multiple smaller files and add each as a separate source.","Convert to a more compact format (e.g. extract text from the PDF and use --content).","Upload the large file through the NotebookLM web UI as the error message suggests."],"exampleFix":"// before\naddSource({ file: 'big-recording.mp4' }); // 500MB\n// after\nconst stat = fs.statSync('big-recording.mp4');\n// extract audio/transcript or compress first, then:\naddSource({ file: 'transcript.txt' });","handlingStrategy":"validation","validationCode":"const stat = fs.statSync(filePath);\nif (stat.size > MAX_FILE_SOURCE_BYTES) {\n  throw new Error(`File too large for upload: ${stat.size} > ${MAX_FILE_SOURCE_BYTES} bytes`);\n}","typeGuard":"function isWithinUploadLimit(p, max = MAX_FILE_SOURCE_BYTES) {\n  try { const s = fs.statSync(p); return s.isFile() && s.size <= max; } catch { return false; }\n}","tryCatchPattern":"try {\n  await addSource({ file: filePath });\n} catch (e) {\n  if (e instanceof ArgumentError && e.message.includes('--file exceeds')) {\n    console.error('Compress, split, or upload this file via the NotebookLM UI.');\n  } else throw e;\n}","preventionTips":["Check file size against MAX_FILE_SOURCE_BYTES before invoking.","Compress or downscale large PDFs/media ahead of time.","Split oversized documents into smaller files in your pipeline.","Remember the CLI limit is stricter than the web UI's."],"tags":["file-size","argument-validation","notebooklm","limits"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}