{"record":{"id":"1ec75b049c4a08b7","repo":"jackwener/OpenCLI","slug":"file-not-found","errorCode":"FILE_NOT_FOUND","errorMessage":"File not found: ${resolvedPath}","messagePattern":"File not found: (.+?)","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/paperreview/utils.js","lineNumber":65,"sourceCode":"    return numeric;\n}\nexport async function readPdfFile(inputPath) {\n    const rawPath = trimOrEmpty(inputPath);\n    if (!rawPath) {\n        throw new CliError('ARGUMENT', 'A PDF path is required.', 'Provide a local PDF file path');\n    }\n    const resolvedPath = path.resolve(rawPath);\n    const fileName = path.basename(resolvedPath);\n    if (!fileName.toLowerCase().endsWith('.pdf')) {\n        throw new CliError('ARGUMENT', 'The input file must end with .pdf.', 'Provide a PDF file path');\n    }\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');","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/paperreview/utils.js#L47-L83","documentation":"readPdfFile calls fs.stat on the resolved path and translates ENOENT into CliError with code FILE_NOT_FOUND and the absolute path in the message. This confirms the extension was valid but no file exists at that location. Other stat errors (e.g. permissions) become FILE_READ_ERROR instead.","triggerScenarios":"Passing a well-formed .pdf path that does not exist: typo in the name, file deleted/moved, wrong working directory with a relative path, or a symlink pointing nowhere.","commonSituations":"Typos in file names; running the CLI from a different cwd than expected in scripts; files on unmounted drives; cleanup jobs removing generated PDFs before submission.","solutions":["Use the absolute path printed in the message to confirm what the CLI looked for; verify the file exists with ls.","cd to the right directory or pass an absolute path.","Re-generate or restore the PDF if it was deleted.","Check symlink targets if the path is a link."],"exampleFix":"// before\ncli submit --pdf papre.pdf   # typo\n// after\ncli submit --pdf /abs/path/paper.pdf","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs';\ntry {\n  statSync(path.resolve(pdfPath));\n} catch (e) {\n  if (e.code === 'ENOENT') throw new Error(`PDF does not exist: ${path.resolve(pdfPath)}`);\n}","typeGuard":"function pdfExists(v) {\n  try { return statSync(path.resolve(v)).isFile(); } catch { return false; }\n}","tryCatchPattern":"try {\n  await cli.submit({ pdf: pdfPath });\n} catch (err) {\n  if (err.code === 'FILE_NOT_FOUND') console.error(`No such file: ${err.message}`);\n  else if (err.code === 'FILE_READ_ERROR') console.error('Check file permissions');\n  else throw err;\n}","preventionTips":["Pass absolute paths to eliminate cwd dependence.","Verify existence with `test -f \"$PDF\"` in shell wrappers.","Regenerate the PDF if build/cleanup jobs may have removed it.","Resolve symlinks before submitting."],"tags":["file","filesystem","not-found"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}