{"record":{"id":"c0b0ae29770c542a","repo":"jackwener/OpenCLI","slug":"xianyu-publish-submit-failed-submitresult-reas","errorCode":null,"errorMessage":"Xianyu publish submit failed: ${submitResult?.reason || 'unknown-reason'}","messagePattern":"Xianyu publish submit failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/publish.js","lineNumber":437,"sourceCode":"            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 = '';\n        let finalUrl = await getCurrentPageUrl(page);\n        let failReason = '';\n\n        for (let i = 0; i < 10; i++) {\n            await page.wait(1.5);\n            const result = await page.evaluate(buildDetectSuccessEvaluate());\n            finalUrl = await getCurrentPageUrl(page);\n\n            if (result?.status === 'published') {\n                itemId = String(result.item_id || '').replace(/\\D/g, '');\n                return [{\n                    status: 'published',\n                    item_id: itemId,","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/publish.js#L419-L455","documentation":"After filling the form and uploading images, publish evaluates buildSubmitEvaluate() to click the publish (发布) button. If the injected script returns ok:false — button not found, disabled, or the click failed — the CLI throws with the script's reason. Publishing never got initiated.","triggerScenarios":"`xianyu publish` reaching step 6 where buildSubmitEvaluate returns ok:false: the submit button selector changed, the button is disabled because a required field failed validation, or a risk-control overlay blocks the click.","commonSituations":"Goofish UI update moving/renaming the publish button; form has client-side validation errors (e.g. price/title invalid) keeping the button disabled; an anti-bot dialog intercepting interaction; images still uploading when submit is attempted.","solutions":["Read `reason` from the message; if it says the button was disabled/missing, check the form state in the browser and fix field values.","Retry after increasing the post-fill/post-upload waits so the page settles before clicking submit.","Verify you are not on a login/captcha interstitial; re-authenticate if so.","If goofish changed its DOM, update buildSubmitEvaluate selectors."],"exampleFix":"// before\nconst submitResult = await page.evaluate(buildSubmitEvaluate());\n// after: give uploads time to finish before submitting\nawait page.wait(3);\nconst submitResult = await page.evaluate(buildSubmitEvaluate());","handlingStrategy":"retry","validationCode":"// confirm the publish button is present and enabled before submitting\nconst ready = await page.evaluate(() => {\n  const b = [...document.querySelectorAll('button')].find((x) => /发布|publish/i.test(x.textContent || ''));\n  return !!b && !b.disabled;\n});","typeGuard":null,"tryCatchPattern":"try {\n  await publish(data);\n} catch (e) {\n  if (String(e.message).includes('publish submit failed')) {\n    await page.wait(3); // let validation/uploads settle\n    return publish(data); // single retry\n  }\n  throw e;\n}","preventionTips":["Fill all required fields with valid values so the submit button stays enabled.","Wait for image uploads to finish before submitting in custom flows.","Check for login/captcha interstitials before publishing.","Re-verify submit-button selectors after goofish UI updates."],"tags":["dom-selector","form-submit","browser-automation","xianyu"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}