jackwener/OpenCLI · error · CommandExecutionError

Could not find image file input on Weibo compose page. UI ma

Error message

Could not find image file input on Weibo compose page. UI may have changed.

What it means

Thrown when the CLI cannot locate the hidden <input type="file"> element on the Weibo compose page using the selector input[type="file"][class*="_file_"]. The command uses this input to stage image files, so without it image upload cannot proceed. Weibo ships its frontend with CSS-module class hashes that change on every rebuild, so this is a UI-drift guard.

Source

Thrown at clis/weibo/publish.js:173

        if (!editorFound) {
            throw new CommandExecutionError('Weibo compose editor did not appear');
        }

        // Step 5: Upload images first (before text to avoid editor reset)
        if (absPaths.length > 0) {
            if (!page.setFileInput) {
                throw new CommandExecutionError('Browser extension does not support file upload. Please update the extension.');
            }

            // Find the file input
            const fileInputFound = await page.evaluate(`
                () => {
                    const input = document.querySelector('input[type="file"][class*="_file_"]');
                    return !!input;
                }
            `);
            if (!fileInputFound) {
                throw new CommandExecutionError('Could not find image file input on Weibo compose page. UI may have changed.');
            }

            await page.setFileInput(absPaths, FILE_INPUT_SELECTOR);

            // Wait for upload to complete
            let uploadResult = null;
            for (let i = 0; i < Math.ceil(UPLOAD_TIMEOUT_MS / UPLOAD_POLL_MS); i++) {
                await page.wait({ time: UPLOAD_POLL_MS / 1000 });
                uploadResult = await page.evaluateWithArgs(`
                    (() => {
                        const expectedCount = expected;
                        const uploading = document.querySelector('[class*="upload"], [class*="progress"]');
                        if (uploading && uploading.offsetParent !== null) return null;
                        const pics = document.querySelectorAll('img[class*="pic"], [class*="imgItem"], [class*="picture"] img');
                        if (pics.length >= expectedCount) return { ok: true, count: pics.length };
                        return null;
                    })()
                `, { expected: absPaths.length });

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry later — often a transient render issue or a Weibo frontend rollout in progress
  2. Update the CLI to a version with refreshed Weibo selectors (check the repo for selector-fix commits)
  3. Open weibo.com manually and confirm the desktop compose dialog shows an image-attach button
  4. As a workaround, publish without images and attach them manually
Defensive patterns

Strategy: try-catch

Validate before calling

const fileInput = await page.evaluate(`() => !!document.querySelector('input[type="file"][class*="_file_"]')`);
if (!fileInput) {
    console.warn('Weibo compose file input not found; publish will fail. Check weibo.com UI or update the CLI.');
}

Try / catch

try {
    await publishToWeibo(text, images);
} catch (err) {
    if (String(err.message).includes('file input')) {
        // fall back to text-only publish
        await publishToWeibo(text, []);
    } else throw err;
}

Prevention

When it happens

Trigger: page.evaluate check `document.querySelector('input[type="file"][class*="_file_"]')` returns null after the compose editor opened, while images were requested.

Common situations: Weibo redeployed their frontend and the file input's class name no longer contains the `_file_` module fragment; the compose modal failed to fully render (slow network, A/B layout test); the user is on a mobile/alternate Weibo layout where the desktop compose UI is absent.

Related errors


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