jackwener/OpenCLI · error · CommandExecutionError

文字配图: could not click "${TEXT_IMAGE_ENTRY_LABEL}" entry. Deb

Error message

文字配图: could not click "${TEXT_IMAGE_ENTRY_LABEL}" entry. Debug: /tmp/xhs_publish_textimage_debug.png

What it means

runTextImageFlow starts the 文字配图 sub-flow by clicking the entry button found via its label (TEXT_IMAGE_ENTRY_LABEL, e.g. the 文字配图 option on the media picker). If clickByText can't click it, a debug screenshot is saved to /tmp/xhs_publish_textimage_debug.png and this error is thrown.

Source

Thrown at clis/xiaohongshu/publish.js:1054

    const state = await currentComposerMediaCount(page);
    if (!state || typeof state.count !== 'number') {
        throw new CommandExecutionError(`${label}: could not verify current composer media count`);
    }
    if (state.count < expectedCount) {
        await page.screenshot({ path: '/tmp/xhs_publish_media_debug.png' });
        throw new CommandExecutionError(`${label}: expected at least ${expectedCount} visible media item(s), got ${state.count}. ` +
            'Debug screenshot: /tmp/xhs_publish_media_debug.png');
    }
}
/**
 * Drive the full 文字配图 sub-flow: entry → type cards → 生成图片 → pick style → 下一步.
 * Leaves the page on the standard editor (caller then runs waitForEditForm).
 */
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);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect /tmp/xhs_publish_textimage_debug.png to see the actual page state at failure.
  2. Retry with a wait before the flow so the media picker finishes rendering.
  3. Retry outright — click races on the lazy-loaded entry are often transient.
  4. If XHS changed the label, update TEXT_IMAGE_ENTRY_LABEL to match the current on-page text.

Example fix

// before
await runTextImageFlow(page, cards, style);
// after
await page.wait({ time: 2.0 }); // ensure media picker rendered
try {
  await runTextImageFlow(page, cards, style);
} catch (e) {
  if (/could not click .* entry/.test(e.message)) {
    await page.wait({ time: 3.0 });
    await runTextImageFlow(page, cards, style);
  } else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

await page.wait({ time: 2.0 }); // media picker must be visible first
// optionally assert the entry label exists:
const found = await page.evaluate(`document.body.innerText.includes('${TEXT_IMAGE_ENTRY_LABEL}')`);
if (!found) console.warn('文字配图 entry not on page yet');

Type guard

null

Try / catch

try { await runTextImageFlow(page, cards, style); }
catch (e) {
  if (/could not click .* entry/.test(e.message)) {
    await page.wait({ time: 3.0 });
    await runTextImageFlow(page, cards, style);
  } else throw e;
}

Prevention

When it happens

Trigger: clickByText(page, TEXT_IMAGE_ENTRY_LABEL) returned { ok: false } — entry button not rendered yet, hidden behind an 'add media' popup that hasn't opened, label text changed, or an overlay intercepted the click.

Common situations: Media picker step not fully loaded; XHS renamed/relocated the 文字配图 entry; slow network so the entry card lazy-loads after the click attempt; multiple similar entries confusing text matching.

Related errors


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