{"record":{"id":"09e05785e88a505b","repo":"jackwener/OpenCLI","slug":"warn-total-image-payload-is-totalbytes-1024","errorCode":null,"errorMessage":"[warn] Total image payload is ${(totalBytes / 1024 / 1024).toFixed(1)}MB (base64). This may fail with the browser bridge. Update the extension to v1.6+ for CDP-based upload, or compress images before publishing.","messagePattern":"\\[warn\\] Total image payload is (.+?)MB \\(base64\\)\\. This may fail with the browser bridge\\. Update the extension to v1\\.6\\+ for CDP-based upload, or compress images before publishing\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"clis/xiaohongshu/publish.js","lineNumber":189,"sourceCode":"            const msg = err instanceof Error ? err.message : String(err);\n            if (msg.includes('Unknown action') || msg.includes('not supported') || msg.includes('Not allowed')) {\n                // Extension too old — fall through to legacy base64 method\n            }\n            else {\n                return { ok: false, count: 0, error: msg };\n            }\n        }\n    }\n    // ── Fallback: legacy base64 DataTransfer injection ─────────────────\n    const images = absPaths.map((absPath) => {\n        const base64 = fs.readFileSync(absPath).toString('base64');\n        const ext = path.extname(absPath).toLowerCase();\n        return { name: path.basename(absPath), mimeType: SUPPORTED_EXTENSIONS[ext], base64 };\n    });\n    // Warn if total payload is large — this may fail with older extensions\n    const totalBytes = images.reduce((sum, img) => sum + img.base64.length, 0);\n    if (totalBytes > 500_000) {\n        console.warn(`[warn] Total image payload is ${(totalBytes / 1024 / 1024).toFixed(1)}MB (base64). ` +\n            'This may fail with the browser bridge. Update the extension to v1.6+ for CDP-based upload, ' +\n            'or compress images before publishing.');\n    }\n    const payload = JSON.stringify(images);\n    return page.evaluate(`\n    (async () => {\n      const images = ${payload};\n\n      const inputs = Array.from(document.querySelectorAll('input[type=\"file\"]'));\n      const input = inputs.find(el => {\n        const accept = el.getAttribute('accept') || '';\n        return (\n          accept.includes('image') ||\n          accept.includes('.jpg') ||\n          accept.includes('.jpeg') ||\n          accept.includes('.png') ||\n          accept.includes('.gif') ||\n          accept.includes('.webp')","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L171-L207","documentation":"uploadImages warns when the combined base64 size of all images to publish exceeds ~500KB, because large JSON payloads may fail through the browser bridge's page.evaluate on extensions older than v1.6 (no CDP-based upload).","triggerScenarios":"Publishing a Xiaohongshu note where sum of base64 lengths across all attached images exceeds 500,000 characters with a pre-v1.6 extension installed.","commonSituations":"Publishing multiple high-resolution photos at once, images not compressed beforehand, older extension, multi-image notes where each image alone is under the limit but the total is not.","solutions":["Update the browser extension to v1.6+ for CDP-based upload","Compress or resize each image before publishing (JPEG/WebP, ~1280px)","Reduce the number of images per publish and split into multiple notes if needed","If publish fails after the warning, retry with smaller images rather than retrying identical payloads"],"exampleFix":"// before\nopencli xiaohongshu publish --images a.png b.png c.png  # 6MB total, warn\n// after: pre-compress\nfor f in a b c; do npx sharp -i $f.png -o $f.jpg resize 1280; done\nopencli xiaohongshu publish --images a.jpg b.jpg c.jpg","handlingStrategy":"validation","validationCode":"const total = images.reduce((s, f) => s + fs.statSync(f).size, 0);\nif (total * 4 / 3 > 500_000) {\n  console.warn('Total payload too large for browser bridge; compress images.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await publish(page, note);\n} catch (err) {\n  if (/upload|payload|evaluate/i.test(err.message)) {\n    await publish(page, { ...note, images: note.images.map(compressImage) });\n  }\n}","preventionTips":["Estimate total base64 size (bytes * 4/3) across all images before publish","Compress each image (≤1280px JPEG/WebP) before multi-image publishes","Update the extension to v1.6+ for CDP-based upload","Split very large notes into smaller publishes instead of retrying oversized payloads"],"tags":["payload-size","base64","browser-bridge","xiaohongshu","image-upload"],"backgroundTag":"payload-too-large","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}