jackwener/OpenCLI · error · CommandExecutionError
WeChat create-draft failed: ${message}
Error message
WeChat create-draft failed: ${message} What it means
This error wraps any unexpected failure in the `weixin create-draft` command into a CommandExecutionError (code COMMAND_EXEC, exit code 1). The command automates mp.weixin.qq.com to create a draft article; any thrown non-CliError value (browser page errors, navigation failures, timeouts, upload failures) is caught, its message extracted, and re-thrown with the 'WeChat create-draft failed:' prefix. CliError subclasses (like ArgumentError or AuthRequiredError) are re-thrown untouched to preserve their codes and hints.
Source
Thrown at clis/weixin/create-draft.js:327
if (coverSet !== true) {
throw new CommandExecutionError('WeChat uploaded the image but did not confirm it as the draft cover.');
}
}
if (kwargs.summary) {
const summaryResult = await fillField(page, 'textarea#js_description', kwargs.summary);
if (!summaryResult?.ok) throw new CommandExecutionError('Failed to fill summary');
}
await saveDraft(page);
return [{
status: 'draft saved',
detail: `"${kwargs.title}"${kwargs.author ? ` by ${kwargs.author}` : ''}${coverImage ? ' (with cover)' : ''}`,
}];
} catch (error) {
if (error instanceof CliError) throw error;
const message = error instanceof Error ? error.message : String(error);
throw new CommandExecutionError(`WeChat create-draft failed: ${message}`);
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped inner message after 'WeChat create-draft failed:' — it identifies the actual failing step
- Re-authenticate: open Chrome/Chromium, log in to mp.weixin.qq.com, then retry the command
- Retry the command — transient network or browser timing issues often resolve on a second run
- If the error persists, check for WeChat backend UI changes and report the issue; update the opencli weixin adapter if a fix is released
Example fix
// before
await cli.run(['weixin', 'create-draft', '--title', 'Hello']);
// after
try {
await cli.run(['weixin', 'create-draft', '--title', 'Hello']);
} catch (e) {
if (e instanceof CliError && e.code === 'COMMAND_EXEC') {
console.error('Create-draft failed:', e.message, 'hint:', e.hint);
// e.g. re-login to mp.weixin.qq.com, then retry
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// verify session before running create-draft const url = await page.url?.() ?? ''; // or simply pre-check by running: opencli weixin drafts // if it throws AUTH_REQUIRED, re-login first.
Type guard
function isCliError(e) { return e instanceof Error && 'code' in e && 'exitCode' in e; } Try / catch
try {
await run(['weixin', 'create-draft', '--title', t]);
} catch (e) {
if (e instanceof CliError && e.code === 'AUTH_REQUIRED') { /* re-login */ }
else if (e instanceof CliError && e.code === 'COMMAND_EXEC') { /* inspect e.message inner cause, retry once */ }
else throw e;
} Prevention
- Ensure an active mp.weixin.qq.com login before creating drafts (run a read command like `weixin drafts` as a probe)
- Keep arguments stable: valid title/author/cover path to reduce mid-flow failures
- Retry once on transient failures before surfacing the error
- Keep the opencli weixin adapter updated for WeChat UI changes
When it happens
Trigger: Calling `opencli weixin create-draft` when the underlying browser automation throws: the mp.weixin.qq.com draft page fails to load, the title/author/cover submission step times out, an element the automation clicks cannot be found, or any non-CliError exception escapes the try block.
Common situations: WeChat mp.weixin.qq.com UI changed so selectors no longer match; expired or unlogged-in WeChat session causing a login wall mid-flow; network flakiness or slow page loads causing page.wait timeouts; invalid cover image path or upload rejection; unexpected popup/dialog in the page.
Related errors
- Failed to upload file to ChatGPT project knowledge
- Failed to send message to ChatGPT
- Failed to read GeoGebra object property: ${err?.message || e
- Manus whoami failed: ${probe.detail}
- Unexpected Rednote probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8ab4f69cb3b5223f.
Report an issue: GitHub.