jackwener/OpenCLI · error · CommandExecutionError

Xianyu ${label} failed: ${result.reason || 'unknown-reason'}

Error message

Xianyu ${label} failed: ${result.reason || 'unknown-reason'}

What it means

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'.

Source

Thrown at clis/xianyu/im.js:52

export function requireText(value, label) {
    const text = String(value ?? '').replace(/\s+/g, ' ').trim();
    if (!text) {
        throw new ArgumentError(`${label} cannot be empty`);
    }
    return text;
}

export function requireEvaluateObject(payload, label) {
    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
        throw new CommandExecutionError(`Xianyu ${label} returned malformed browser payload`);
    }
    return payload;
}

export function requireClickResult(payload, label) {
    const result = requireEvaluateObject(payload, label);
    if (result.ok !== true) {
        throw new CommandExecutionError(`Xianyu ${label} failed: ${result.reason || 'unknown-reason'}`);
    }
    return result;
}

export function buildChatUrl(itemId, peerUserId) {
    return `https://www.goofish.com/im?itemId=${encodeURIComponent(itemId)}&peerUserId=${encodeURIComponent(peerUserId)}`;
}

export function buildInboxUrl() {
    return 'https://www.goofish.com/im';
}

export function buildClickInboxConversationEvaluate(index) {
    return `
    (() => {
      const rows = Array.from(document.querySelectorAll('#conv-list-scrollable [class*="conversation-item"], a[href*="/im"], a[href*="itemId="][href*="peerUserId="]'));
      const row = rows[${index}];
      if (!row) return { ok: false, reason: 'row-not-found' };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read result.reason from the error message ('row-not-found', 'send-button-not-found', etc.) and apply the matching fix
  2. Re-run the command; if 'row-not-found', re-list the inbox first so row indexes are fresh
  3. If selectors consistently fail, check for a goofish.com UI update and update the library's DOM selectors
  4. For 'send-postcondition-timeout', check network latency and whether the message actually appeared despite the timeout
  5. Verify you are on the correct chat page and logged in before the click script runs

Example fix

// before
requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rowIndex)), 'inbox resolve-ids click');
// after
try {
  requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rowIndex)), 'inbox resolve-ids click');
} catch (e) {
  await page.goto(buildInboxUrl());
  await page.wait(4);
  // re-list to get fresh row indexes, then retry the click
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

function isClickOk(result) {
  return result !== null && typeof result === 'object' && !Array.isArray(result) && result.ok === true;
}

Try / catch

try {
  requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(i)), 'click');
} catch (e) {
  const m = /failed: ([\w-]+)/.exec(String(e));
  if (m && m[1] === 'row-not-found') {
    // re-list inbox to refresh row indexes, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/bf0ac78b3e96ccd1. Report an issue: GitHub.