jackwener/OpenCLI · error · CliError

FILE_NOT_FOUND

FILE_NOT_FOUND

Error message

FILE_NOT_FOUND

What it means

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.

Source

Thrown at clis/yollomi/upload.js:33

    '.png': 'image/png', '.gif': 'image/gif',
    '.webp': 'image/webp',
    '.mp4': 'video/mp4', '.mov': 'video/quicktime',
};
cli({
    site: 'yollomi',
    name: 'upload',
    access: 'write',
    description: 'Upload an image or video to Yollomi (returns URL for other commands)',
    domain: YOLLOMI_DOMAIN,
    strategy: Strategy.COOKIE,
    args: [
        { name: 'file', positional: true, required: true, help: 'Local file path to upload' },
    ],
    columns: ['status', 'file', 'size', 'url'],
    func: async (page, kwargs) => {
        const filePath = path.resolve(kwargs.file);
        if (!fs.existsSync(filePath))
            throw new CliError('FILE_NOT_FOUND', `File not found: ${filePath}`, 'Provide a valid file path');
        const ext = path.extname(filePath).toLowerCase();
        const mime = MIME_MAP[ext];
        if (!mime)
            throw new CliError('INVALID_TYPE', `Unsupported file type: ${ext}`, 'Supported: jpg, png, gif, webp, mp4, mov');
        const data = fs.readFileSync(filePath);
        // Note: base64 encoding inflates size ~33%. Video cap is conservative to avoid
        // OOM when the base64 string is injected into the browser JS engine via page.evaluate().
        const maxSize = mime.startsWith('video/') ? 20 * 1024 * 1024 : 10 * 1024 * 1024;
        if (data.length > maxSize)
            throw new CliError('FILE_TOO_LARGE', `File too large: ${fmtBytes(data.length)}`, `Max ${mime.startsWith('video/') ? '20MB' : '10MB'} (upload larger videos from a URL)`);
        const b64 = data.toString('base64');
        const fileName = path.basename(filePath);
        log.status(`Uploading ${fileName} (${fmtBytes(data.length)})...`);
        await ensureOnYollomi(page);
        const result = await page.evaluate(`
      (async () => {
        try {
          const raw = atob(${JSON.stringify(b64)});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the resolved path in the error message and fix typos (per the hint)
  2. Use an absolute path to avoid cwd ambiguity
  3. Verify the file exists: ls <path> (or dir on Windows)
  4. Quote paths containing spaces; check glob expansion with echo <pattern>

Example fix

// before
opencli yollomi upload ~/Images/photo heic
// error: File not found: /home/user/Images/photo heic
// after
opencli yollomi upload "/home/user/Images/photo heic.jpg"
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs'), path = require('path');
function assertUploadable(p) {
  const fp = path.resolve(p);
  if (!fs.existsSync(fp)) throw new Error(`File not found: ${fp}`);
  if (!/\.(jpe?g|png|gif|webp|mp4|mov)$/i.test(fp)) throw new Error(`Unsupported type: ${path.extname(fp)}`);
  return fp;
}

Try / catch

try {
  const rows = await opencli.yollomi.upload(filePath);
} catch (e) {
  if (e.code === 'FILE_NOT_FOUND') {
    console.error(`${e.message} — cwd is ${process.cwd()}; use an absolute path or fix the typo`);
  } else throw e;
}

Prevention

When it happens

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

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

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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