{"record":{"id":"bf0ac78b3e96ccd1","repo":"jackwener/OpenCLI","slug":"xianyu-label-failed-result-reason-unknow","errorCode":null,"errorMessage":"Xianyu ${label} failed: ${result.reason || 'unknown-reason'}","messagePattern":"Xianyu (.+?) failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/im.js","lineNumber":52,"sourceCode":"export function requireText(value, label) {\n    const text = String(value ?? '').replace(/\\s+/g, ' ').trim();\n    if (!text) {\n        throw new ArgumentError(`${label} cannot be empty`);\n    }\n    return text;\n}\n\nexport function requireEvaluateObject(payload, label) {\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError(`Xianyu ${label} returned malformed browser payload`);\n    }\n    return payload;\n}\n\nexport function requireClickResult(payload, label) {\n    const result = requireEvaluateObject(payload, label);\n    if (result.ok !== true) {\n        throw new CommandExecutionError(`Xianyu ${label} failed: ${result.reason || 'unknown-reason'}`);\n    }\n    return result;\n}\n\nexport function buildChatUrl(itemId, peerUserId) {\n    return `https://www.goofish.com/im?itemId=${encodeURIComponent(itemId)}&peerUserId=${encodeURIComponent(peerUserId)}`;\n}\n\nexport function buildInboxUrl() {\n    return 'https://www.goofish.com/im';\n}\n\nexport function buildClickInboxConversationEvaluate(index) {\n    return `\n    (() => {\n      const rows = Array.from(document.querySelectorAll('#conv-list-scrollable [class*=\"conversation-item\"], a[href*=\"/im\"], a[href*=\"itemId=\"][href*=\"peerUserId=\"]'));\n      const row = rows[${index}];\n      if (!row) return { ok: false, reason: 'row-not-found' };","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/im.js#L34-L70","documentation":"Thrown by requireClickResult after requireEvaluateObject validates the payload: the browser click script returned an object but with ok !== true. The injected click script reports { ok: false, reason: 'row-not-found' } (or other reasons like 'input-not-found', 'send-button-not-found', 'send-postcondition-timeout'), and the reason is surfaced in the message, defaulting to 'unknown-reason'.","triggerScenarios":"Calling a command that clicks a conversation row (e.g. xianyu inbox --resolve-ids) or sends a message when the clicked row index no longer exists on the page, the DOM selectors changed, the send button/textarea is absent, or the post-click verification times out — the evaluate payload comes back with ok:false and a reason string.","commonSituations":"The inbox re-rendered between listing and clicking so row_index points at a removed row; goofish.com UI update changed the conversation-item/button selectors; the chat page loaded without a textarea ( conversation not fully opened); network slowness making the 3-second send-postcondition loop time out.","solutions":["Read result.reason from the error message ('row-not-found', 'send-button-not-found', etc.) and apply the matching fix","Re-run the command; if 'row-not-found', re-list the inbox first so row indexes are fresh","If selectors consistently fail, check for a goofish.com UI update and update the library's DOM selectors","For 'send-postcondition-timeout', check network latency and whether the message actually appeared despite the timeout","Verify you are on the correct chat page and logged in before the click script runs"],"exampleFix":"// before\nrequireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rowIndex)), 'inbox resolve-ids click');\n// after\ntry {\n  requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rowIndex)), 'inbox resolve-ids click');\n} catch (e) {\n  await page.goto(buildInboxUrl());\n  await page.wait(4);\n  // re-list to get fresh row indexes, then retry the click\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"function isClickOk(result) {\n  return result !== null && typeof result === 'object' && !Array.isArray(result) && result.ok === true;\n}","tryCatchPattern":"try {\n  requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(i)), 'click');\n} catch (e) {\n  const m = /failed: ([\\w-]+)/.exec(String(e));\n  if (m && m[1] === 'row-not-found') {\n    // re-list inbox to refresh row indexes, then retry\n  } else throw e;\n}","preventionTips":["Always re-list the inbox immediately before clicking rows with --resolve-ids","Expect DOM selector drift after goofish UI updates; keep the library updated","Don't navigate away between listing and clicking","Treat 'send-postcondition-timeout' as possibly-sent and verify before resending"],"tags":["browser-automation","dom-click","command-execution"],"backgroundTag":"dom-action-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}