{"record":{"id":"3bdf2bc947b7f6ef","repo":"jackwener/OpenCLI","slug":"unsupported-image-format-ext-supported-jpg-3bdf2b","errorCode":null,"errorMessage":"Unsupported image format \"${ext}\". Supported: jpg, png, gif, webp","messagePattern":"Unsupported image format \"(.+?)\"\\. Supported: jpg, png, gif, webp","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/publish.js","lineNumber":132,"sourceCode":"        && typeof value.session === 'string'\n        && Object.prototype.hasOwnProperty.call(value, 'data')\n    ) {\n        return value.data;\n    }\n    return value;\n}\n/**\n * Validate image paths: check existence and extension.\n * Returns resolved absolute paths.\n */\nfunction validateImagePaths(filePaths) {\n    return filePaths.map((filePath) => {\n        const absPath = path.resolve(filePath);\n        if (!fs.existsSync(absPath))\n            throw new ArgumentError(`Image file not found: ${absPath}`);\n        const ext = path.extname(absPath).toLowerCase();\n        if (!SUPPORTED_EXTENSIONS[ext]) {\n            throw new ArgumentError(`Unsupported image format \"${ext}\". Supported: jpg, png, gif, webp`);\n        }\n        return absPath;\n    });\n}\n/** CSS selector for image-accepting file inputs. */\nconst IMAGE_INPUT_SELECTOR = 'input[type=\"file\"][accept*=\"image\"],'\n    + 'input[type=\"file\"][accept*=\".jpg\"],'\n    + 'input[type=\"file\"][accept*=\".jpeg\"],'\n    + 'input[type=\"file\"][accept*=\".png\"],'\n    + 'input[type=\"file\"][accept*=\".gif\"],'\n    + 'input[type=\"file\"][accept*=\".webp\"]';\n/**\n * Upload images via CDP DOM.setFileInputFiles — Chrome reads files directly\n * from the local filesystem, avoiding base64 payload size limits.\n *\n * Falls back to the legacy base64 DataTransfer approach if the extension\n * does not support set-file-input (e.g. older extension version).\n */","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/publish.js#L114-L150","documentation":"ArgumentError from validateImagePaths: the image file exists but its extension (lowercased) is not a key in SUPPORTED_EXTENSIONS (jpg, png, gif, webp). XHS's uploader only accepts these formats, so the CLI rejects other files up front.","triggerScenarios":"Passing .jpeg, .bmp, .tiff, .heic, .avif, or extensionless files to publish; files downloaded without an extension; uppercase extensions are fine (extname is lowercased), but exotic ones are not.","commonSituations":"iPhone HEIC photos, .jpeg naming, screenshots saved as .tiff on macOS, or images with missing extensions from downloads.","solutions":["Convert the image to jpg/png/webp (e.g. `sips -s format jpeg in.heic --out out.jpg` or ImageMagick `convert`).","Rename `.jpeg` to `.jpg` if that is the only issue — or convert if .jpeg is not in the supported map.","Add the correct extension if the file was downloaded without one.","Check the extension actually matches the file content (file command) to avoid upload failure later."],"exampleFix":"// before\nawait xhs.publish({ images: ['photo.heic'] });\n// after\n// convert first: magick photo.heic photo.jpg\nawait xhs.publish({ images: ['photo.jpg'] });","handlingStrategy":"validation","validationCode":"const OK = new Set(['.jpg', '.png', '.gif', '.webp']);\nfor (const p of images) {\n  const ext = require('path').extname(p).toLowerCase();\n  if (!OK.has(ext)) throw new Error(`Convert ${p} (${ext}) to jpg/png/gif/webp first`);\n}","typeGuard":"function isSupportedImage(p) {\n  return ['.jpg', '.png', '.gif', '.webp']\n    .includes(require('path').extname(String(p)).toLowerCase());\n}","tryCatchPattern":"try {\n  await xhs.publish({ images });\n} catch (err) {\n  if (err.message.startsWith('Unsupported image format')) {\n    console.error('Convert the file, e.g. magick in.heic out.jpg');\n  } else throw err;\n}","preventionTips":["Convert HEIC/AVIF/TIFF photos to jpg before publishing","Normalize .jpeg to .jpg in your pipeline","Ensure downloaded images have proper extensions","Validate extensions in a pre-publish step"],"tags":["validation","argument-error","image-format","xiaohongshu"],"backgroundTag":"unsupported-image-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}