{"record":{"id":"034ce8b9facbb545","repo":"jackwener/OpenCLI","slug":"xianyu-image-upload-input-was-not-found-fileinp","errorCode":null,"errorMessage":"Xianyu image upload input was not found: ${fileInput?.reason || 'unknown-reason'}","messagePattern":"Xianyu image upload input was not found: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/publish.js","lineNumber":424,"sourceCode":"        }\n        await page.wait(1.5);\n\n        // 4. 填充表单\n        const fillResult = await page.evaluate(buildFillFormEvaluate(data));\n        if (!fillResult?.ok) {\n            const missing = Array.isArray(fillResult?.missing) ? fillResult.missing.join(', ') : 'unknown';\n            throw new CommandExecutionError(`Xianyu publish form fill failed; missing fields: ${missing}`);\n        }\n        await page.wait(1);\n\n        // 5. 上传图片（如果有）\n        if (data.images.length > 0) {\n            if (!page.setFileInput) {\n                throw new CommandExecutionError('Xianyu publish requires Browser Bridge file upload support', 'Use a browser mode that supports setFileInput.');\n            }\n            const fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());\n            if (!fileInput?.ok) {\n                throw new CommandExecutionError(`Xianyu image upload input was not found: ${fileInput?.reason || 'unknown-reason'}`);\n            }\n            try {\n                await page.setFileInput(data.images, fileInput.selector || 'input[type=\"file\"]');\n                await page.wait(3); // 等待图片上传处理\n            } catch (err) {\n                throw new CommandExecutionError(`Xianyu image upload failed: ${err?.message || err}`);\n            }\n        }\n\n        // 6. 点击发布按钮\n        const submitResult = await page.evaluate(buildSubmitEvaluate());\n        if (!submitResult?.ok) {\n            throw new CommandExecutionError(`Xianyu publish submit failed: ${submitResult?.reason || 'unknown-reason'}`);\n        }\n\n        // 7. 等待发布结果（最多 15 秒轮询）\n        await page.wait(2);\n        let itemId = '';","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/publish.js#L406-L442","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Re-run after ensuring the publish page fully loads; the flow already waits 1s after form fill, so retry often succeeds.","Verify you are logged in on www.goofish.com and the page shows the real publish form, not a login/captcha screen.","Check the `reason` in the message; if it indicates missing input, inspect the current goofish DOM and update buildFindFileInputSelectorEvaluate selectors."],"exampleFix":"// before: evaluate immediately after form fill\nconst fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());\n// after: wait for the uploader to render first\nawait page.wait(3);\nconst fileInput = await page.evaluate(buildFindFileInputSelectorEvaluate());","handlingStrategy":"retry","validationCode":"const state = await page.evaluate(() => !!document.querySelector('input[type=\"file\"]'));\nif (!state) await page.wait(3); // let the uploader widget render before publishing","typeGuard":null,"tryCatchPattern":"try {\n  await publish({ ...data, images });\n} catch (e) {\n  if (String(e.message).includes('image upload input was not found')) {\n    await page.wait(3);\n    return publish({ ...data, images }); // retry after the widget renders\n  }\n  throw e;\n}","preventionTips":["Ensure a logged-in session so the real publish form loads, not a login/captcha page.","Allow the publish page to fully render before invoking the CLI in scripted flows.","After goofish UI updates, re-check the file-input finder selectors."],"tags":["dom-selector","browser-automation","xianyu","file-upload"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}