{"record":{"id":"9240bf07044f465b","repo":"jackwener/OpenCLI","slug":"weixin-create-draft-cover-image-does-not-exist","errorCode":null,"errorMessage":"weixin create-draft cover-image does not exist: ${absPath}","messagePattern":"weixin create-draft cover-image does not exist: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/weixin/create-draft.js","lineNumber":41,"sourceCode":"\nasync function evaluate(page, script) {\n    return unwrapEvaluateResult(await page.evaluate(script));\n}\n\nfunction isRecoverableFileInputError(error) {\n    const message = error instanceof Error ? error.message : String(error);\n    return /unknown action|not supported|not[-\\s]?allowed|notallowederror/i.test(message);\n}\n\nfunction resolveCoverImage(rawPath) {\n    const value = String(rawPath ?? '').trim();\n    if (!value) throw new ArgumentError('weixin create-draft cover-image cannot be empty');\n    const absPath = path.resolve(value);\n    let stat;\n    try {\n        stat = fs.statSync(absPath);\n    } catch {\n        throw new ArgumentError(`weixin create-draft cover-image does not exist: ${absPath}`);\n    }\n    if (!stat.isFile()) {\n        throw new ArgumentError(`weixin create-draft cover-image is not a file: ${absPath}`);\n    }\n    const extension = path.extname(absPath).toLowerCase();\n    const mimeType = IMAGE_MIME_TYPES.get(extension);\n    if (!mimeType) {\n        throw new ArgumentError('weixin create-draft cover-image must be JPEG, PNG, GIF, or WebP');\n    }\n    return { absPath, fileName: path.basename(absPath), mimeType };\n}\n\nasync function navigateToEditor(page) {\n    await page.goto(WEIXIN_HOME);\n    await page.wait(3);\n    const token = await evaluate(page, `(window.location.href.match(/token=(\\\\d+)/)||[])[1]`);\n    if (!token) {\n        throw new AuthRequiredError(WEIXIN_DOMAIN, 'Please log in to the WeChat Official Account platform and retry.');","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weixin/create-draft.js#L23-L59","documentation":"After resolving and normalizing the cover image path, resolveCoverImage calls fs.statSync; if the path does not exist (or is inaccessible) it throws this ArgumentError including the absolute path that was checked.","triggerScenarios":"Passing a cover-image path that does not exist on disk, contains a typo, uses a wrong relative base for path.resolve, or points to a permission-denied location.","commonSituations":"Typos in the filename; running the CLI from a different working directory than assumed; image deleted/moved before the run; container missing the mounted file.","solutions":["Verify the file exists at the printed absolute path (ls the path).","Pass an absolute path to avoid working-directory surprises.","Fix file permissions if access is denied.","Check volume mounts if running inside a container."],"exampleFix":"// before\ncoverImage: './cover.png'\n// after\ncoverImage: '/home/me/assets/cover.png' // verified with ls","handlingStrategy":"validation","validationCode":"const abs = path.resolve(coverImage);\nif (!fs.existsSync(abs)) throw new Error(`cover image missing: ${abs}`);","typeGuard":"function isExistingFile(p) {\n  try { return fs.statSync(path.resolve(p)).isFile(); } catch { return false; }\n}","tryCatchPattern":"try {\n  await createDraft({ coverImage });\n} catch (err) {\n  if (err instanceof ArgumentError && err.message.includes('does not exist')) {\n    console.error('Check the path printed in the error');\n  } else throw err;\n}","preventionTips":["Use absolute paths for cover images","Check working directory assumptions for relative paths","Verify files exist before long automation runs","Check container volume mounts"],"tags":["weixin","argument-error","filesystem","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}