jackwener/OpenCLI · error · CommandExecutionError

Xianyu image upload input was not found: ${fileInput?.reason

Error message

Xianyu image upload input was not found: ${fileInput?.reason || 'unknown-reason'}

What it means

After confirming setFileInput exists, publish injects buildFindFileInputSelectorEvaluate() into the publish page to locate the file input. If the injected script returns {ok:false} (input not found, page not loaded, or DOM changed), the CLI throws with the script's reason. It means the upload form's <input type="file"> was not discoverable at that moment.

Source

Thrown at clis/xianyu/publish.js:424

        }
        await page.wait(1.5);

        // 4. 填充表单
        const fillResult = await page.evaluate(buildFillFormEvaluate(data));
        if (!fillResult?.ok) {
            const missing = Array.isArray(fillResult?.missing) ? fillResult.missing.join(', ') : 'unknown';
            throw new CommandExecutionError(`Xianyu publish form fill failed; missing fields: ${missing}`);
        }
        await page.wait(1);

        // 5. 上传图片(如果有)
        if (data.images.length > 0) {
            if (!page.setFileInput) {
                throw new CommandExecutionError('Xianyu publish requires Browser Bridge file upload support', 'Use a browser mode that supports setFileInput.');
            }
            const fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());
            if (!fileInput?.ok) {
                throw new CommandExecutionError(`Xianyu image upload input was not found: ${fileInput?.reason || 'unknown-reason'}`);
            }
            try {
                await page.setFileInput(data.images, fileInput.selector || 'input[type="file"]');
                await page.wait(3); // 等待图片上传处理
            } catch (err) {
                throw new CommandExecutionError(`Xianyu image upload failed: ${err?.message || err}`);
            }
        }

        // 6. 点击发布按钮
        const submitResult = await page.evaluate(buildSubmitEvaluate());
        if (!submitResult?.ok) {
            throw new CommandExecutionError(`Xianyu publish submit failed: ${submitResult?.reason || 'unknown-reason'}`);
        }

        // 7. 等待发布结果(最多 15 秒轮询)
        await page.wait(2);
        let itemId = '';

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run after ensuring the publish page fully loads; the flow already waits 1s after form fill, so retry often succeeds.
  2. Verify you are logged in on www.goofish.com and the page shows the real publish form, not a login/captcha screen.
  3. Check the `reason` in the message; if it indicates missing input, inspect the current goofish DOM and update buildFindFileInputSelectorEvaluate selectors.

Example fix

// before: evaluate immediately after form fill
const fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());
// after: wait for the uploader to render first
await page.wait(3);
const fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());
Defensive patterns

Strategy: retry

Validate before calling

const state = await page.evaluate(() => !!document.querySelector('input[type="file"]'));
if (!state) await page.wait(3); // let the uploader widget render before publishing

Try / catch

try {
  await publish({ ...data, images });
} catch (e) {
  if (String(e.message).includes('image upload input was not found')) {
    await page.wait(3);
    return publish({ ...data, images }); // retry after the widget renders
  }
  throw e;
}

Prevention

When it happens

Trigger: `xianyu publish` with images while the injected finder on the goofish publish page returns ok:false — e.g. the upload widget has not rendered yet, the page is showing a login/captcha interstitial, or the file input selector in the DOM changed.

Common situations: Slow page load or network so the uploader component is absent when the script runs; logged-out or risk-control (captcha) page instead of the publish form; goofish front-end update renaming the upload input.

Related errors


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