jackwener/OpenCLI · error · CommandExecutionError

文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step.

Error message

文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step. Debug: /tmp/xhs_publish_generate_debug.png

What it means

Thrown when clicking GENERATE_LABEL ('生成图片') does not advance the flow to the 预览图片 (preview image) step. `clickGenerate(page)` returned false, indicating the expected preview step was not detected after the click. A debug screenshot is saved to /tmp/xhs_publish_generate_debug.png before throwing.

Source

Thrown at clis/xiaohongshu/publish.js:1076

        await page.screenshot({ path: '/tmp/xhs_publish_textimage_debug.png' });
        throw new CommandExecutionError(`文字配图: 写文字 card editor did not appear after clicking "${TEXT_IMAGE_ENTRY_LABEL}". ` +
            'Debug: /tmp/xhs_publish_textimage_debug.png');
    }
    for (let i = 0; i < cards.length; i++) {
        if (i > 0) {
            const added = await addCard(page, i + 1);
            if (!added) {
                await page.screenshot({ path: '/tmp/xhs_publish_addcard_debug.png' });
                throw new CommandExecutionError(`文字配图: new card editor #${i + 1} did not render after "${ADD_CARD_LABEL}". ` +
                    'Debug: /tmp/xhs_publish_addcard_debug.png');
            }
        }
        await fillCard(page, cards[i], i);
    }
    const generated = await clickGenerate(page);
    if (!generated) {
        await page.screenshot({ path: '/tmp/xhs_publish_generate_debug.png' });
        throw new CommandExecutionError(`文字配图: "${GENERATE_LABEL}" did not advance to the 预览图片 step. ` +
            'Debug: /tmp/xhs_publish_generate_debug.png');
    }
    const appliedStyle = await selectCardStyle(page, cardStyle);
    const next = await clickByText(page, PREVIEW_NEXT_LABEL);
    if (!next?.ok) {
        await page.screenshot({ path: '/tmp/xhs_publish_next_debug.png' });
        throw new CommandExecutionError(`文字配图: could not click "${PREVIEW_NEXT_LABEL}". ` +
            'Debug: /tmp/xhs_publish_next_debug.png');
    }
    await page.wait({ time: 2 }); // editor render
    return appliedStyle;
}
async function inspectPublishSurfaceState(page) {
    return page.evaluate(`
    () => {
      const text = (document.body?.innerText || '').replace(/\s+/g, ' ').trim();
      const hasTitleInput = !!Array.from(document.querySelectorAll('input, textarea')).find((el) => {
        if (!el || el.offsetParent === null) return false;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect /tmp/xhs_publish_generate_debug.png for error toasts or a changed page layout
  2. Retry — image generation can be slow; increase the wait before declaring failure
  3. Verify the '生成图片' button text still matches GENERATE_LABEL in clis/xiaohongshu/publish.js and update it if XHS changed the label
  4. Shorten card text / remove problematic characters that may fail server-side rendering
  5. Check XHS creator center status (service outage or captcha/rate-limit)

Example fix

// before
const generated = await clickGenerate(page);
if (!generated) { ... throw ... }
// after
const generated = await clickGenerate(page);
if (!generated) {
  await page.wait({ time: 5 });
  generated = await clickGenerate(page);
}
if (!generated) { ... throw ... }
Defensive patterns

Strategy: retry

Validate before calling

// pre-check card text length/content sanity before invoking
const okCards = cards.every(c => c.length > 0 && c.length < 500);
if (!okCards) throw new Error('card text out of safe range for generation');

Try / catch

try {
  await publish(page, opts);
} catch (e) {
  if (String(e.message).includes('did not advance to the 预览图片 step')) {
    // inspect /tmp/xhs_publish_generate_debug.png, wait longer, retry once
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the text-image publish flow: all cards were filled successfully, but after clicking '生成图片' the page did not show the 预览图片 step within the wait timeout.

Common situations: Card content invalid or too long causing server-side generation failure with an inline error toast; XHS renamed the step/button text; generation service slow or degraded; anti-bot rate limiting after many publishes; a required card style not yet selected.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/21aab79c93bcd5be. Report an issue: GitHub.