jackwener/OpenCLI · error · CommandExecutionError

Unexpected xueqiu probe: ${JSON.stringify(probe)}

Error message

Unexpected xueqiu probe: ${JSON.stringify(probe)}

What it means

Final safety net in verifyXueqiuIdentity: if the probe result is neither ok nor any known kind (auth/http/xq-error/exception), the verifier throws CommandExecutionError with the JSON-serialized probe. This guards against an unexpected probe shape — typically null/undefined from page.evaluate returning nothing or the probe protocol changing.

Source

Thrown at clis/xueqiu/auth.js:46

      }
      if (d?.error_code) {
        return { kind: 'xq-error', errorCode: d.error_code, detail: d.error_description || 'xueqiu API error' };
      }
      const uCookie = document.cookie.split('; ').find(c => c.startsWith('u='))?.split('=')[1] || '';
      const cookiesuCookie = document.cookie.split('; ').find(c => c.startsWith('cookiesu='))?.split('=')[1] || '';
      if (!uCookie || uCookie === cookiesuCookie) {
        return { kind: 'auth', detail: 'xueqiu u cookie equals cookiesu (device id) — anonymous despite portfolio API 200' };
      }
      return { ok: true, user_id: uCookie };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('xueqiu.com', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from xueqiu stock API: ${probe.detail || ''}`);
  if (probe?.kind === 'xq-error') throw new CommandExecutionError(`xueqiu API error_code ${probe.errorCode}: ${probe.detail}`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`xueqiu whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected xueqiu probe: ${JSON.stringify(probe)}`);
  return { user_id: String(probe.user_id) };
}

registerSiteAuthCommands({
  site: 'xueqiu',
  domain: 'xueqiu.com',
  loginUrl: 'https://xueqiu.com/',
  columns: ['user_id'],
  quickCheck: hasXueqiuAccessToken,
  verify: verifyXueqiuIdentity,
  poll: async (page) => {
    if (!await hasXueqiuAccessToken(page)) {
      throw new AuthRequiredError('xueqiu.com', 'Waiting for Xueqiu xq_a_token cookie');
    }
    return verifyXueqiuIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command — a transient evaluate failure often resolves on retry
  2. Ensure the automation browser stays open on xueqiu.com during verify (avoid navigating away mid-probe)
  3. Re-login and retry; if it persists, report with the JSON probe shown in the message
  4. Check for library updates if the probe script and verifier could be out of sync

Example fix

// before
await page.goto('other-site');
await verifyXueqiuIdentity(page);
// after
await page.goto('https://xueqiu.com/');
await verifyXueqiuIdentity(page);
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the page is on xueqiu before verifying
const url = page.url();
if (!url.includes('xueqiu.com')) await page.goto('https://xueqiu.com/');

Type guard

function isKnownProbe(p) {
  return !!p && typeof p === 'object'
    && ['auth','http','xq-error','exception'].includes(p.kind) || p?.ok === true;
}

Try / catch

try {
  await verifyXueqiuIdentity(page);
} catch (e) {
  if (e.message.startsWith('Unexpected xueqiu probe')) {
    // transient evaluate failure — retry once
    await verifyXueqiuIdentity(page);
  } else throw e;
}

Prevention

When it happens

Trigger: page.evaluate returns null/undefined (page closed, script failed to serialize) or the in-page script returns an object without a recognized kind and without ok:true.

Common situations: Browser crashed or page navigated during evaluate so the promise resolved to null; an older/newer browser driver returning a non-serializable result; library-internal contract drift between the probe script and the verifier.

Related errors


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