jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

verifyChaoxingIdentity expects the in-page probe to return either kind:'auth' or ok:true. Any other shape (undefined probe, unexpected object, page script error swallowed into a malformed result) triggers this CommandExecutionError containing the JSON of the probe. It signals the site returned a state the library doesn't recognize — a probe/parse bug or an unexpected page variant, not necessarily an auth problem.

Source

Thrown at clis/chaoxing/auth.js:37

      }
      const userIdCookie = (document.cookie.split('; ').find(c => /^(_uid|UID)=/.test(c)) || '').split('=')[1] || '';
      let userName = '';
      const unameCookie = (document.cookie.split('; ').find(c => /^uname=/.test(c)) || '').split('=')[1] || '';
      if (unameCookie) {
        try { userName = decodeURIComponent(unameCookie); } catch { userName = unameCookie; }
      }
      if (!userName) {
        const el = document.querySelector('.userTitle, .myInfo, .user-name, [class*=userName]');
        userName = (el?.innerText || '').trim();
      }
      if (!userIdCookie && !userName) {
        return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com no user identity surface — anonymous' };
      }
      return { ok: true, user_id: userIdCookie, name: userName };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'chaoxing',
  domain: 'chaoxing.com',
  loginUrl: 'https://passport2.chaoxing.com/login?fid=&newversion=true&refer=https%3A%2F%2Fi.chaoxing.com',
  columns: ['user_id', 'name'],
  quickCheck: hasChaoxingSessionCookie,
  verify: verifyChaoxingIdentity,
  poll: async (page) => {
    if (!await hasChaoxingSessionCookie(page)) {
      throw new AuthRequiredError('chaoxing.com', 'Waiting for Chaoxing session cookies');
    }
    return verifyChaoxingIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the JSON in the message — it shows exactly what the probe returned
  2. Increase the wait/retry after page.goto so evaluation runs on the fully loaded i.chaoxing.com page
  3. Re-login and retry to rule out an intermediate redirect page
  4. Update the probe script if Chaoxing changed the identity surface (cookie names/DOM)
  5. If probe is null/undefined, wrap evaluate in try/catch and rethrow a clearer error

Example fix

// before
const probe = await page.evaluate(`...`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);
// after
let probe;
try { probe = await page.evaluate(`...`); }
catch (e) { throw new CommandExecutionError(`Chaoxing probe evaluate failed: ${e.message}`); }
if (!probe) { await page.wait(3); probe = await page.evaluate(`...`); } // retry once after load
Defensive patterns

Strategy: try-catch

Validate before calling

await page.goto('https://i.chaoxing.com/', { waitUntil: 'domcontentloaded' });
if (!page.url().includes('i.chaoxing.com')) throw new Error('Unexpected redirect: ' + page.url());

Type guard

function isProbeResult(p) { return !!p && typeof p === 'object' && ('ok' in p || 'kind' in p); }

Try / catch

let probe;
try { probe = await whoami(page); }
catch (e) {
  if (e instanceof CommandExecutionError && e.message.startsWith('Unexpected Chaoxing probe')) {
    await page.wait(3); return whoami(page); // retry after full load
  }
  throw e;
}

Prevention

When it happens

Trigger: The page.evaluate probe throws or returns undefined/null (navigation interrupted, page landed on an unexpected intermediate page, JS error in the probe), or returns an object with neither kind='auth' nor ok=true.

Common situations: Chaoxing deployed a new i.chaoxing.com layout breaking the probe's DOM/cookie reads; page.goto raced with a redirect so evaluate ran on about:blank; page.wait(3) too short for slow networks.

Related errors


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