jackwener/OpenCLI · error · ArgumentError
${label} exceeds Midjourney's 10MB upload limit: ${ref.value
Error message
${label} exceeds Midjourney's 10MB upload limit: ${ref.value} What it means
Midjourney's upload endpoint accepts images up to 10MB (MAX_REFERENCE_BYTES). When a local reference's stat size exceeds this constant, the library throws this ArgumentError before starting the browser upload, avoiding a guaranteed-to-fail transfer.
Source
Thrown at clis/midjourney/utils.js:913
if (error instanceof ArgumentError) throw error;
}
return { kind: 'url', value: item };
}
const expanded = item === '~' ? os.homedir() : item.startsWith('~/') ? path.join(os.homedir(), item.slice(2)) : item;
return { kind: 'local', value: path.resolve(expanded) };
});
}
export async function validateLocalReferences(refs, label) {
for (const ref of refs.filter((item) => item.kind === 'local')) {
let stat;
try {
stat = await fs.stat(ref.value);
} catch {
throw new ArgumentError(`${label} file does not exist: ${ref.value}`);
}
if (!stat.isFile() || stat.size <= 0) throw new ArgumentError(`${label} must reference a non-empty file: ${ref.value}`);
if (stat.size > MAX_REFERENCE_BYTES) throw new ArgumentError(`${label} exceeds Midjourney's 10MB upload limit: ${ref.value}`);
const ext = path.extname(ref.value).toLowerCase();
if (!IMAGE_EXTENSIONS.has(ext)) throw new ArgumentError(`${label} must be PNG, JPEG, WEBP, or GIF: ${ref.value}`);
}
return refs;
}
async function visibleImageSources(page) {
const payload = unwrapEvaluateResult(await page.evaluate(() => [...document.querySelectorAll('img[src]')]
.filter((img) => {
const rect = img.getBoundingClientRect();
let card = img.parentElement;
while (card && !String(card.className).includes('group/img')) card = card.parentElement;
return Boolean(card) && rect.width > 24 && rect.height > 24 && /cdn\.midjourney\.com\/u\//.test(img.src);
})
.map((img) => img.src)));
return Array.isArray(payload) ? payload.map(String) : [];
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Resize/compress the image below 10MB (e.g. magick input.png -resize 2048x -quality 85 output.webp)
- Re-export as JPEG/WEBP at lower quality
- Crop or downscale before passing to the CLI
Example fix
// before clis/midjourney --refs ./4k-render.png // 18MB // after magick ./4k-render.png -resize 2048x2048 -quality 85 ./render.webp clis/midjourney --refs ./render.webp
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 10 * 1024 * 1024; const s = await fs.stat(p); if (s.size > MAX) await compressImage(p); // e.g. magick p -resize 2048x -quality 85 out.webp
Type guard
const withinUploadLimit = async (p, max = 10 * 1024 * 1024) => (await fs.stat(p)).size <= max;
Try / catch
try {
await validateLocalReferences(refs, 'refs');
} catch (e) {
if (String(e.message).includes("10MB upload limit")) {
console.error('Compress/resize the image below 10MB:', e.message);
}
throw e;
} Prevention
- Pre-check file size against 10MB in automation before uploads
- Export images at web-appropriate resolutions (<=2048px) by default
- Prefer JPEG/WEBP for photographic sources to keep sizes small
When it happens
Trigger: A local PNG/JPEG/WEBP/GIF whose byte size exceeds 10MB — full-resolution exports, high-DPI screenshots, raw scans, or long animated GIFs.
Common situations: Designers exporting 4K renders, lossless screen recordings saved as GIF, camera originals, or datasets with source-resolution imagery.
Related errors
- File not found: ${path}
- File must be a readable text file: ${path}
- 视频文件不存在: ${videoPath}
- Video file not found: ${resolved}
- Receipt file cannot be read: ${receipt}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/09d48195f60a5179.
Report an issue: GitHub.