{"record":{"id":"c44384f9011b1829","repo":"jackwener/OpenCLI","slug":"chrome-goofish-com","errorCode":null,"errorMessage":"发布闲鱼需要先登录，请在 Chrome 中打开 goofish.com 并完成登录","messagePattern":"发布闲鱼需要先登录，请在 Chrome 中打开 goofish\\.com 并完成登录","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/publish.js","lineNumber":396,"sourceCode":"        { name: 'description', required: true, positional: true, help: '商品描述/详情' },\n        { name: 'price', required: true, positional: true, type: 'float', help: '出售价格（元）' },\n        { name: 'condition', required: true, positional: true, help: '成色：全新 / 几乎全新 / 轻微使用 / 明显使用 / 老旧' },\n        { name: 'category', required: true, positional: true, help: '商品分类关键词（如：手机、衣服、图书）' },\n        { name: 'original_price', type: 'float', help: '原价（选填，用于显示折扣）' },\n        { name: 'location', help: '所在地区（选填，如：杭州）' },\n        { name: 'images', help: '本地图片路径，多张用逗号分隔（选填，如：/tmp/a.jpg,/tmp/b.jpg）' },\n    ],\n    columns: ['status', 'item_id', 'title', 'price', 'condition', 'url', 'message'],\n    func: async (page, kwargs) => {\n        const data = normalizePublishArgs(kwargs);\n        // 1. 导航到发布页\n        await page.goto(buildPublishUrl());\n        await page.wait(3);\n\n        // 2. 检查登录状态\n        const initState = await page.evaluate(buildExtractPageStateEvaluate());\n        if (initState?.requiresAuth) {\n            throw new AuthRequiredError('www.goofish.com', '发布闲鱼需要先登录，请在 Chrome 中打开 goofish.com 并完成登录');\n        }\n        if (!initState?.hasPublishForm) {\n            throw new CommandExecutionError('Xianyu publish form was not detected', 'Confirm goofish.com is logged in and the publish page finished loading.');\n        }\n\n        // 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        }","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/publish.js#L378-L414","documentation":"The publish flow opens goofish.com's publish page, extracts page state, and throws AuthRequiredError when the state reports requiresAuth — the browser session is not logged into Xianyu/goofish. The library cannot publish without an authenticated Chrome profile, so it stops with a login instruction.","triggerScenarios":"Running xianyu publish while the attached Chrome profile has no valid goofish.com session: initState.requiresAuth is true after page.goto(buildPublishUrl()).","commonSituations":"Fresh automation profile that never logged in, expired session cookies, manual logout, cookies cleared by browser cleanup, or pointing at the wrong Chrome profile directory.","solutions":["Open goofish.com in the Chrome profile used by the CLI and complete login (including QR scan), then rerun publish","Point the CLI at the Chrome user-data-dir/profile where you are already logged in","Re-login and verify goofish.com shows your account before retrying"],"exampleFix":"// before (no login)\nawait publish(data); // AuthRequiredError\n// after: log in to goofish.com in the target Chrome profile, then\nawait publish(data); // proceeds","handlingStrategy":"try-catch","validationCode":"const state = await page.evaluate(buildExtractPageStateEvaluate());\nif (state?.requiresAuth) {\n  throw new Error('Not logged into goofish.com — complete login in Chrome first');\n}","typeGuard":"function isLoggedIn(state) {\n  return Boolean(state && !state.requiresAuth);\n}","tryCatchPattern":"try {\n  await publish(data);\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    console.error(`Login required for goofish.com: open the site in Chrome and log in, then retry`);\n  } else throw e;\n}","preventionTips":["Verify the session by loading goofish.com before batch publish jobs","Use a persistent Chrome user-data-dir so cookies survive restarts","Re-login proactively; don't run long unattended jobs on stale sessions"],"tags":["auth","session","browser-automation"],"backgroundTag":"auth-required-login","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}