jackwener/OpenCLI · error · ArgumentError

--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.si

Error message

--file exceeds ${MAX_FILE_SOURCE_BYTES} bytes (got ${stat.size}); use a smaller file or upload via the NotebookLM UI for now.

What it means

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.

Source

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

export function inferMimeType(filename, override) {
    if (override) return String(override);
    const ext = path.extname(filename).toLowerCase();
    return MIME_BY_EXT[ext] || 'application/octet-stream';
}

export function readFileForUpload(filePath) {
    const abs = path.resolve(filePath);
    let stat;
    try {
        stat = fs.statSync(abs);
    } catch {
        throw new ArgumentError(`--file path does not exist: ${filePath}`);
    }
    if (!stat.isFile()) {
        throw new ArgumentError(`--file path is not a regular file: ${filePath}`);
    }
    if (stat.size > MAX_FILE_SOURCE_BYTES) {
        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.`);
    }
    const buf = fs.readFileSync(abs);
    return { base64: buf.toString('base64'), filename: path.basename(abs), size: stat.size };
}

export function buildRegisterFileSourceArgs(projectId, filename) {
    return [
        [[filename]],
        projectId,
        [2],
        [1, null, null, null, null, null, null, null, null, null, [1]],
    ];
}

export function parseSourceUrl(value) {
    const url = String(value ?? '').trim();
    if (!url) return '';
    let parsed;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Compress or downscale the file (PDF compression, lower-resolution export) so it fits under MAX_FILE_SOURCE_BYTES.
  2. Split the content into multiple smaller files and add each as a separate source.
  3. Convert to a more compact format (e.g. extract text from the PDF and use --content).
  4. Upload the large file through the NotebookLM web UI as the error message suggests.

Example fix

// before
addSource({ file: 'big-recording.mp4' }); // 500MB
// after
const stat = fs.statSync('big-recording.mp4');
// extract audio/transcript or compress first, then:
addSource({ file: 'transcript.txt' });
Defensive patterns

Strategy: validation

Validate before calling

const stat = fs.statSync(filePath);
if (stat.size > MAX_FILE_SOURCE_BYTES) {
  throw new Error(`File too large for upload: ${stat.size} > ${MAX_FILE_SOURCE_BYTES} bytes`);
}

Type guard

function isWithinUploadLimit(p, max = MAX_FILE_SOURCE_BYTES) {
  try { const s = fs.statSync(p); return s.isFile() && s.size <= max; } catch { return false; }
}

Try / catch

try {
  await addSource({ file: filePath });
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('--file exceeds')) {
    console.error('Compress, split, or upload this file via the NotebookLM UI.');
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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