{"record":{"id":"de940e46d14b8827","repo":"jackwener/OpenCLI","slug":"file-not-found-de940e","errorCode":"FILE_NOT_FOUND","errorMessage":"FILE_NOT_FOUND","messagePattern":"FILE_NOT_FOUND","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/yollomi/upload.js","lineNumber":33,"sourceCode":"    '.png': 'image/png', '.gif': 'image/gif',\n    '.webp': 'image/webp',\n    '.mp4': 'video/mp4', '.mov': 'video/quicktime',\n};\ncli({\n    site: 'yollomi',\n    name: 'upload',\n    access: 'write',\n    description: 'Upload an image or video to Yollomi (returns URL for other commands)',\n    domain: YOLLOMI_DOMAIN,\n    strategy: Strategy.COOKIE,\n    args: [\n        { name: 'file', positional: true, required: true, help: 'Local file path to upload' },\n    ],\n    columns: ['status', 'file', 'size', 'url'],\n    func: async (page, kwargs) => {\n        const filePath = path.resolve(kwargs.file);\n        if (!fs.existsSync(filePath))\n            throw new CliError('FILE_NOT_FOUND', `File not found: ${filePath}`, 'Provide a valid file path');\n        const ext = path.extname(filePath).toLowerCase();\n        const mime = MIME_MAP[ext];\n        if (!mime)\n            throw new CliError('INVALID_TYPE', `Unsupported file type: ${ext}`, 'Supported: jpg, png, gif, webp, mp4, mov');\n        const data = fs.readFileSync(filePath);\n        // Note: base64 encoding inflates size ~33%. Video cap is conservative to avoid\n        // OOM when the base64 string is injected into the browser JS engine via page.evaluate().\n        const maxSize = mime.startsWith('video/') ? 20 * 1024 * 1024 : 10 * 1024 * 1024;\n        if (data.length > maxSize)\n            throw new CliError('FILE_TOO_LARGE', `File too large: ${fmtBytes(data.length)}`, `Max ${mime.startsWith('video/') ? '20MB' : '10MB'} (upload larger videos from a URL)`);\n        const b64 = data.toString('base64');\n        const fileName = path.basename(filePath);\n        log.status(`Uploading ${fileName} (${fmtBytes(data.length)})...`);\n        await ensureOnYollomi(page);\n        const result = await page.evaluate(`\n      (async () => {\n        try {\n          const raw = atob(${JSON.stringify(b64)});","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/yollomi/upload.js#L15-L51","documentation":"The yollomi upload command throws FILE_NOT_FOUND when the positional `file` argument does not exist on disk after path.resolve(). fs.existsSync is checked before reading so the command fails fast with the resolved absolute path in the message.","triggerScenarios":"Running `opencli yollomi upload <file>` where <file> is misspelled, relative to a different working directory, deleted/moved, or a shell glob that did not expand.","commonSituations":"Running from a different cwd than expected so relative paths break; typos in the path; file deleted between listing and upload; spaces in the filename unescaped/quoting issues; Windows-style paths used on POSIX.","solutions":["Check the resolved path in the error message and fix typos (per the hint)","Use an absolute path to avoid cwd ambiguity","Verify the file exists: ls <path> (or dir on Windows)","Quote paths containing spaces; check glob expansion with echo <pattern>"],"exampleFix":"// before\nopencli yollomi upload ~/Images/photo heic\n// error: File not found: /home/user/Images/photo heic\n// after\nopencli yollomi upload \"/home/user/Images/photo heic.jpg\"","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nfunction assertUploadable(p) {\n  const fp = path.resolve(p);\n  if (!fs.existsSync(fp)) throw new Error(`File not found: ${fp}`);\n  if (!/\\.(jpe?g|png|gif|webp|mp4|mov)$/i.test(fp)) throw new Error(`Unsupported type: ${path.extname(fp)}`);\n  return fp;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await opencli.yollomi.upload(filePath);\n} catch (e) {\n  if (e.code === 'FILE_NOT_FOUND') {\n    console.error(`${e.message} — cwd is ${process.cwd()}; use an absolute path or fix the typo`);\n  } else throw e;\n}","preventionTips":["Resolve to absolute paths in scripts before invoking upload","Quote file paths containing spaces in the shell","Check fs.existsSync(path) yourself before calling to give better errors","Beware cwd differences: relative paths resolve against process.cwd(), not the script location"],"tags":["file-not-found","filesystem","cli","validation"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}