{"record":{"id":"e8b49f4e8105b2da","repo":"jackwener/OpenCLI","slug":"xianyu-publish-requires-browser-bridge-file-upload","errorCode":null,"errorMessage":"Xianyu publish requires Browser Bridge file upload support","messagePattern":"Xianyu publish requires Browser Bridge file upload support","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/publish.js","lineNumber":420,"sourceCode":"        // 3. 选择分类（先于其他字段，因为分类可能影响表单结构）\n        const categoryResult = await page.evaluate(buildSelectCategoryEvaluate(data.category));\n        if (!categoryResult?.ok) {\n            throw new CommandExecutionError(`Xianyu category selection failed: ${categoryResult?.reason || 'unknown-reason'}`);\n        }\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        }","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/publish.js#L402-L438","documentation":"The xianyu publish flow uploads listing images through page.setFileInput, a capability provided only by Browser Bridge-backed page objects. When the connected browser mode lacks that method (e.g. a cookie/simple page adapter), the CLI aborts before touching the page. It is a hard capability check, thrown before any upload is attempted.","triggerScenarios":"Running `xianyu publish` with data.images.length > 0 while the resolved page object does not implement setFileInput — checked at clis/xianyu/publish.js:419 via `if (!page.setFileInput)`.","commonSituations":"Using a browser mode/adapter that only supports page.evaluate and goto (no file upload bridge); running through an older opencli Browser Bridge version predating setFileInput; swapping in a mock or remote page client without upload support.","solutions":["Run the command in a browser mode that supports setFileInput (full Browser Bridge / local browser), per the error's hint.","Upgrade the Browser Bridge / opencli package to a version whose page object implements setFileInput.","Retry without images (omit data.images) if the listing can be published text-only, then add images manually."],"exampleFix":"// before: legacy page adapter without upload support\npage.evaluate(...); // goto/evaluate only\n// after: launch with Browser Bridge that implements setFileInput\nawait browserBridge.open('https://www.goofish.com', { capabilities: ['setFileInput'] });","handlingStrategy":"validation","validationCode":"if (typeof page.setFileInput !== 'function') {\n  throw new Error('Current browser mode lacks setFileInput; switch to Browser Bridge before publishing images.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on a Browser Bridge browser mode that implements setFileInput for publish workflows.","Pin/upgrade opencli to a version where the page adapter exposes setFileInput.","Feature-check page capabilities at startup of scripts that publish with images."],"tags":["browser-automation","file-upload","capability-check","xianyu"],"backgroundTag":"missing-browser-capability","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}