jackwener/OpenCLI · error · CommandExecutionError
文字配图: requested style "${styleName}" is not available for th
Error message
文字配图: requested style "${styleName}" is not available for this content (options: ${(available?.styles || []).join(' / ') || 'none'}). Choose an available style or omit --card-style to use ${DEFAULT_CARD_STYLE}. What it means
selectCardStyle scrolls the lazy-loaded style strip, reads the real on-page style labels, and throws if the requested styleName was not among them. The error lists the actually available styles so the caller can pick one or omit --card-style to fall back to DEFAULT_CARD_STYLE.
Source
Thrown at clis/xiaohongshu/publish.js:957
const scroller = document.querySelector('.cover-list-container-wrapper')
|| document.querySelector('.cover-list-container');
if (scroller) {
const ch = scroller.clientHeight || 200;
const sh = scroller.scrollHeight;
for (let y = 0; y <= sh + ch; y += Math.max(60, Math.floor(ch / 2))) {
scroller.scrollTop = y;
await new Promise((r) => setTimeout(r, 180));
readAll();
hit = target();
if (hit) { reveal(hit); await new Promise((r) => setTimeout(r, 150)); return { ok: true, styles: seen, found: true }; }
}
scroller.scrollTop = 0;
}
return { ok: seen.length > 0, styles: seen, found: false };
})()
`));
if (!available?.found) {
throw new CommandExecutionError(`文字配图: requested style "${styleName}" is not available for this content `
+ `(options: ${(available?.styles || []).join(' / ') || 'none'}). `
+ `Choose an available style or omit --card-style to use ${DEFAULT_CARD_STYLE}.`);
}
const clicked = await clickByText(page, styleName);
if (!clicked?.ok) {
throw new CommandExecutionError(`文字配图: could not click requested style "${styleName}".`);
}
await page.wait({ time: 0.6 });
return styleName;
}
/**
* Count visible media in the current editor/composer. Text-image generation must
* produce real image cards before we fill title/body or submit; otherwise a
* no-op 生成图片 / 下一步 sequence can publish the wrong draft surface.
*/
async function currentComposerMediaCount(page) {
const result = await page.evaluate(`
(() => {View on GitHub (pinned to 49907e53dc)
Solutions
- Pick one of the styles listed in the error message's options, or omit --card-style to use the default.
- Fix the style name to match XHS's exact on-page label (case/spacing included).
- Re-run if options were 'none' — the strip may not have finished lazy-loading; add a wait before the flow.
- If a style you expect is missing, check the XHS UI manually; XHS rotates available styles.
Example fix
// before node publish.js --text-image --card-style "奶油风" ... // after node publish.js --text-image --card-style "治愈风" ... // a label actually offered, or drop --card-style
Defensive patterns
Strategy: validation
Validate before calling
const available = await listCardStyles(page); // read strip labels first
if (!available.includes(styleName)) {
console.warn(`style "${styleName}" unavailable; using default`);
styleName = undefined; // fall back to DEFAULT_CARD_STYLE
} Type guard
null
Try / catch
try { await selectCardStyle(page, styleName); }
catch (e) {
if (/is not available/.test(e.message)) {
// parse options from message and pick first, or omit style
await selectCardStyle(page, (e.message.match(/options: (.*)\)/)?.[1] || '').split(' / ')[0]);
} else throw e;
} Prevention
- Copy style names exactly as shown in the XHS UI
- Don't hard-code styles — read the strip labels at runtime
- Omit --card-style to always use the safe default
When it happens
Trigger: --card-style <name> was passed but no label in the style strip matched it exactly (clickByText matches on rendered text), either because the style doesn't exist for this content or the name is misspelled/renamed by XHS.
Common situations: Hard-coded style name from an older XHS version no longer offered; typo or differing whitespace in the style name; style strip failed to lazy-load so the list is empty ('none'); style unavailable for the particular card content.
Understand the failure class
Background: Invalid option value errors: "must be one of", "is not a valid", and "only allows" failures explained — this error's family across 23 libraries.
Related errors
- gov-policy ${command} --limit must be a positive integer
- gov-policy ${command} --limit must be <= 20
- manifestPath must point to a JSON array exported by grok/exp
- steam app id "${value}" must be a positive integer
- INVALID_ARGUMENT
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f1088ed746864937.
Report an issue: GitHub.