jackwener/OpenCLI · error · CommandExecutionError

xq-error

Error message

xq-error

What it means

verifyXueqiuIdentity probes the xueqiu portfolio API in-page; if the JSON response carries an unexpected error_code other than the anonymous marker 60201, it throws CommandExecutionError with 'xueqiu API error_code <code>: <detail>'. This means xueqiu returned a 200 with a business-level error envelope the verifier does not map to a known auth/HTTP case.

Source

Thrown at clis/xueqiu/auth.js:44

      if (d?.error_code === 60201) {
        return { kind: 'auth', detail: 'xueqiu portfolio API error_code 60201 用户id无效 — anonymous' };
      }
      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. Note the errorCode in the message and search xueqiu docs/community for its meaning
  2. Re-login at https://xueqiu.com/ to refresh xq_a_token and u cookies, then retry verify
  3. Retry later — many xq error codes are transient site-side issues
  4. If persistent after a fresh login, the API contract may have changed; check for library updates

Example fix

// before
const probe = await verifyXueqiuIdentity(page);
// after (catch and report the code)
try {
  const probe = await verifyXueqiuIdentity(page);
} catch (e) {
  console.error('xueqiu verify failed:', e.message); // contains error_code
}
Defensive patterns

Strategy: try-catch

Type guard

function isXqErrorProbe(p) {
  return !!p && typeof p === 'object' && p.kind === 'xq-error' && p.errorCode != null;
}

Try / catch

try {
  await verifyXueqiuIdentity(page);
} catch (e) {
  const m = /error_code (\d+)/.exec(e.message);
  if (m) console.error(`xueqiu business error ${m[1]} — try re-login`);
  else throw e;
}

Prevention

When it happens

Trigger: The in-page fetch to stock.xueqiu.com/v5/stock/portfolio/stock/list.json returns ok with body JSON d where d.error_code is truthy and not 60201 (e.g. 400016, 403003 or another site-side business error).

Common situations: Xueqiu API contract changes introducing new error codes; account-specific restrictions on the portfolio endpoint; transient site-side errors returned as JSON envelopes.

Related errors


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