{"record":{"id":"af8e8e91beb31dcd","repo":"jackwener/OpenCLI","slug":"selector-af8e8e","errorCode":"SELECTOR","errorMessage":"Could not find element: 闲鱼聊天输入框","messagePattern":"Could not find element: 闲鱼聊天输入框","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/chat.js","lineNumber":33,"sourceCode":"    args: [\n        { name: 'item_id', required: true, positional: true, help: '闲鱼商品 item_id' },\n        { name: 'user_id', required: true, positional: true, help: '聊一聊对方的 user_id / peerUserId' },\n        { name: 'text', help: 'Message to send after opening the chat' },\n    ],\n    columns: ['status', 'peer_name', 'item_title', 'price', 'location', 'message'],\n    func: async (page, kwargs) => {\n        const itemId = normalizeNumericId(kwargs.item_id, 'item_id', '1038951278192');\n        const userId = normalizeNumericId(kwargs.user_id, 'user_id', '3650092411');\n        const url = buildChatUrl(itemId, userId);\n        const text = String(kwargs.text || '').trim();\n        await page.goto(url);\n        await page.wait(2);\n        const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate()), 'chat');\n        if (state?.requiresAuth) {\n            throw new AuthRequiredError('www.goofish.com', 'Xianyu chat requires a logged-in browser session');\n        }\n        if (!state?.can_input) {\n            throw selectorError('闲鱼聊天输入框', '未找到可用的聊天输入框，请确认该会话页已正确加载');\n        }\n        if (!text) {\n            return [{\n                status: 'ready',\n                peer_name: state.peer_name || '',\n                item_title: state.item_title || '',\n                price: state.price || '',\n                location: state.location || '',\n                message: (state.visible_messages || []).slice(-1)[0] || '',\n                peer_user_id: userId,\n                item_id: itemId,\n                url,\n                item_url: state.item_url || '',\n            }];\n        }\n        const sent = requireEvaluateObject(await page.evaluate(buildSendMessageEvaluate(text)), 'chat send');\n        if (!sent?.ok) {\n            throw new CommandExecutionError(`Xianyu chat did not observe the sent message: ${sent?.reason || 'unknown-reason'}`);","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/chat.js#L15-L51","documentation":"selectorError thrown when the Xianyu chat page state extraction succeeds but reports can_input=false — no usable chat input box exists. The library treats this as 'element not found' for the 闲鱼聊天输入框 (chat input) element.","triggerScenarios":"Running the xianyu chat command (clis/xianyu/chat.js) on a session page where the extracted chat state has can_input false — the page loaded but no interactable input was found.","commonSituations":"Chat page not fully loaded after the 2s wait; the conversation view failed to render; Xianyu DOM changed and the state extractor no longer matches the input element; user is on a wrong/redirected page.","solutions":["Reload the conversation page and wait longer for it to render, then retry","Confirm the URL is an actual Xianyu chat conversation page, not a list or redirect target","Re-login if the session is stale (auth was already checked, but degraded sessions can hide the input)","Update buildExtractChatStateEvaluate selectors if Goofish changed their chat DOM"],"exampleFix":"// before: immediate call after navigation\nawait opencli xianyu chat --id 123 --text hi\n// after: ensure page settled\nawait page.reload(); await page.wait(5);\nawait opencli xianyu chat --id 123 --text hi","handlingStrategy":"validation","validationCode":"const state = JSON.parse(await page.evaluate(buildExtractChatStateEvaluate()));\nif (!state || state.requiresAuth) await xianyuLogin();\nif (!state.can_input) throw new Error('Chat input not ready — reload the conversation page');","typeGuard":"function canInput(state) { return Boolean(state && state.can_input === true); }","tryCatchPattern":"try {\n  await opencli xianyu chat --id 123 --text 'hi';\n} catch (e) {\n  if (e.code === 'SELECTOR' && e.message.includes('闲鱼聊天输入框')) {\n    await page.reload(); await page.wait(5);\n    await opencli xianyu chat --id 123 --text 'hi';\n  } else throw e;\n}","preventionTips":["Wait for the composer to render before sending text","Confirm the URL is an open conversation page","Keep chat-state extractors updated with Goofish DOM changes","Re-login when sessions degrade"],"tags":["selector","dom","xianyu"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}