{"record":{"id":"ca80622ef0c901b0","repo":"jackwener/OpenCLI","slug":"file-too-large","errorCode":"FILE_TOO_LARGE","errorMessage":"The PDF is larger than paperreview.ai's 10MB limit.","messagePattern":"The PDF is larger than paperreview\\.ai's 10MB limit\\.","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/paperreview/utils.js","lineNumber":76,"sourceCode":"    }\n    let fileStat;\n    try {\n        fileStat = await fs.stat(resolvedPath);\n    }\n    catch (error) {\n        if (error?.code === 'ENOENT') {\n            throw new CliError('FILE_NOT_FOUND', `File not found: ${resolvedPath}`, 'Provide a valid PDF file path');\n        }\n        throw new CliError('FILE_READ_ERROR', `Unable to inspect file: ${resolvedPath}`, 'Check file permissions and try again');\n    }\n    if (!fileStat.isFile()) {\n        throw new CliError('FILE_NOT_FOUND', `Not a file: ${resolvedPath}`, 'Provide a valid PDF file path');\n    }\n    if (fileStat.size < 100) {\n        throw new CliError('ARGUMENT', 'The PDF is too small. paperreview.ai requires at least 100 bytes.', 'Provide the final paper PDF');\n    }\n    if (fileStat.size > MAX_PDF_BYTES) {\n        throw new CliError('FILE_TOO_LARGE', 'The PDF is larger than paperreview.ai\\'s 10MB limit.', 'Compress the PDF or submit a smaller file');\n    }\n    let buffer;\n    try {\n        buffer = await fs.readFile(resolvedPath);\n    }\n    catch {\n        throw new CliError('FILE_READ_ERROR', `Unable to read file: ${resolvedPath}`, 'Check file permissions and try again');\n    }\n    return {\n        buffer,\n        fileName,\n        resolvedPath,\n        sizeBytes: buffer.byteLength,\n    };\n}\nexport async function requestJson(pathname, init = {}) {\n    let response;\n    try {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/paperreview/utils.js#L58-L94","documentation":"readPdfFile() enforces MAX_PDF_BYTES (10 * 1024 * 1024 = 10MB). If the file's size exceeds 10MB it throws FILE_TOO_LARGE before uploading, because paperreview.ai will not accept PDFs beyond its 10MB limit.","triggerScenarios":"Calling readPdfFile() on a PDF whose fileStat.size > 10485760 bytes — e.g. papers with high-resolution figures, embedded fonts, or scans saved without compression.","commonSituations":"Camera-ready PDFs with 300dpi+ embedded images; LaTeX builds including full vector datasets; scanned manuscripts; arXiv source downloads with large supplementary figures.","solutions":["Compress the PDF (e.g. Ghostscript: gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -o out.pdf in.pdf)","Downsample or recompress figures to JPEG at reasonable DPI before rebuilding","Remove embedded attachments/animations or unused fonts from the LaTeX build","Split or reduce supplementary material and submit only the main paper"],"exampleFix":"// before\nawait readPdfFile('./paper-30mb.pdf');\n// after\n// $ gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -o paper-small.pdf paper-30mb.pdf\nawait readPdfFile('./paper-small.pdf'); // under 10MB","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nconst MAX_PDF_BYTES = 10 * 1024 * 1024;\nfunction assertPdfSize(p) {\n    const size = fs.statSync(p).size;\n    if (size > MAX_PDF_BYTES) throw new Error(`${p} is ${(size / 1048576).toFixed(1)}MB; compress below 10MB first`);\n    return size;\n}","typeGuard":"function isWithinUploadLimit(p) {\n    try { return fs.statSync(p).size <= 10 * 1024 * 1024; } catch { return false; }\n}","tryCatchPattern":"try {\n    const pdf = await readPdfFile(userPath);\n} catch (e) {\n    if (e?.code === 'FILE_TOO_LARGE') {\n        console.error('Compress first: gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -o small.pdf ' + userPath);\n    } else throw e;\n}","preventionTips":["Check `du -h paper.pdf` before submitting; keep under 10MB","Standardize on Ghostscript compression for camera-ready PDFs","Downsample figures to ~300dpi JPEG before LaTeX builds","Strip embedded attachments and supplementary material from the main PDF"],"tags":["validation","file-size","pdf","limit"],"backgroundTag":"file-too-large","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}