jackwener/OpenCLI · error · CommandExecutionError

文字配图: new card editor #${i + 1} did not render after "${ADD_

Error message

文字配图: new card editor #${i + 1} did not render after "${ADD_CARD_LABEL}". Debug: /tmp/xhs_publish_addcard_debug.png

What it means

Thrown by the xhs publish CLI's text-image (文字配图) flow when clicking the '再写一张' button fails to produce a new card editor. `addCard(page, i + 1)` returned a falsy result, meaning the expected additional `.tiptap.ProseMirror` editor never appeared within the wait window. A debug screenshot is saved to /tmp/xhs_publish_addcard_debug.png before throwing so the DOM state at failure time can be inspected.

Source

Thrown at clis/xiaohongshu/publish.js:1067

 */
async function runTextImageFlow(page, cards, cardStyle) {
    const entry = await clickByText(page, TEXT_IMAGE_ENTRY_LABEL);
    if (!entry?.ok) {
        await page.screenshot({ path: '/tmp/xhs_publish_textimage_debug.png' });
        throw new CommandExecutionError(`文字配图: could not click "${TEXT_IMAGE_ENTRY_LABEL}" entry. ` +
            'Debug: /tmp/xhs_publish_textimage_debug.png');
    }
    if (!(await waitForFirstCard(page))) {
        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');
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open /tmp/xhs_publish_addcard_debug.png to see what the page actually showed at failure
  2. Re-run with a longer wait or retry — transient slowness is common
  3. Check whether the '再写一家'/'再写一张' button label changed in the current XHS UI and update ADD_CARD_LABEL in clis/xiaohongshu/publish.js
  4. Verify you are logged in and on the publish editor page (no login redirect or modal overlay)
  5. Reduce card count in --card-text to isolate which card index fails

Example fix

// before
const added = await addCard(page, i + 1);
if (!added) { ... throw ... }
// after
let added = false;
for (let attempt = 0; attempt < 3 && !added; attempt++) {
  await page.wait({ time: 2 });
  added = await addCard(page, i + 1);
}
if (!added) { ... throw ... }
Defensive patterns

Strategy: retry

Validate before calling

const cards = cardText.split('|').map(s => s.trim()).filter(Boolean);
if (cards.length > 1) console.log('will need', cards.length - 1, 'add-card clicks');

Try / catch

try {
  await publish(page, opts);
} catch (e) {
  if (String(e.message).includes('did not render after')) {
    await page.screenshot({ path: '/tmp/addcard_retry.png' });
    // retry once after a longer wait, or fall back to fewer cards
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the publish command with --card-text containing 2+ cards, where clicking the ADD_CARD_LABEL ('再写一张') button did not render card editor #i+1 (i.e. the count of .tiptap.ProseMirror editors did not grow).

Common situations: Xiaohongshu creator-center UI changed so the '再写一张' button label/position differs; page still loading or an overlay (login wall, guide modal) blocks the button; slow network leaving the card editor animation unfinished; a prior card fill left the editor in an unexpected state.

Related errors


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