jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

The in-page identity probe returned something that is neither {kind:'auth'} nor {ok:true} — e.g. null/undefined (evaluate failed or returned nothing) or an unexpected object shape. verifyKeIdentity throws CommandExecutionError with the probe serialized, since this indicates an adapter/runtime failure rather than a normal unauthenticated state.

Source

Thrown at clis/ke/auth.js:32

  await page.wait(2);
  const probe = await page.evaluate(`
    (() => {
      const loginBtn = document.querySelector('.btn-login, a[class*=actLoginBtn], .login-btn');
      if (loginBtn && /登录|登陆/.test(loginBtn.innerText || '')) {
        return { kind: 'auth', detail: 'Ke shows 登录 button — anonymous session' };
      }
      // 2026-08 贝壳新版 SSR:用户名在 .typeShowUser(脱敏手机号如 15****93),
      // 旧锚点 .userNick/.user-name/.myInfo 已下线,故把 .typeShowUser 提到最前。
      const el = document.querySelector('.typeShowUser a span, .typeShowUser a, .userNick, .user-name, .myInfo a, [class*=userNick]');
      const username = (el?.innerText || '').trim();
      if (!username) {
        return { kind: 'auth', detail: 'Ke no user-name DOM anchor — anonymous or SSR failed' };
      }
      return { ok: true, username };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('ke.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Ke probe: ${JSON.stringify(probe)}`);
  return { username: probe.username };
}

registerSiteAuthCommands({
  site: 'ke',
  domain: 'ke.com',
  loginUrl: 'https://clogin.ke.com/login/?service=https%3A%2F%2Fwww.ke.com',
  columns: ['username'],
  verify: verifyKeIdentity,
  poll: async (page) => {
    if (!await hasKeSessionCookie(page)) {
      throw new AuthRequiredError('ke.com', 'Waiting for Ke lianjia_token cookie');
    }
    return verifyKeIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command; transient navigation races often resolve
  2. Check the serialized probe in the message to see what actually came back (null vs object)
  3. Ensure the page stays on www.ke.com (no redirect) during verify; re-goto before probing
  4. Update the page driver/automation library if evaluate is systematically broken

Example fix

// before
const probe = await page.evaluate(script); // undefined after navigation
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Ke probe: ${JSON.stringify(probe)}`);
// after
let probe = await page.evaluate(script);
if (probe == null) { await page.goto('https://www.ke.com/'); await page.wait(2); probe = await page.evaluate(script); }
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = await page.evaluate(script).catch(err => ({ __evalError: String(err) }));
if (probe == null || probe.__evalError) {
  console.warn('in-page probe failed; re-navigating before retry');
  await page.goto('https://www.ke.com/');
}

Type guard

function isWellFormedProbe(p) {
  return p != null && (('ok' in p && p.ok === true) || (p.kind === 'auth' && typeof p.detail === 'string'));
}

Try / catch

try {
  await keVerify(page);
} catch (e) {
  if (/Unexpected Ke probe/.test(e.message)) {
    await page.goto('https://www.ke.com/');
    await page.wait(3);
    return keVerify(page); // single retry after re-navigation
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate throws or returns undefined (navigation destroyed the execution context, CSP blocks eval, page closed); the probe script itself errors and the host swallows it into null; a middleware/interceptor returns a non-standard value from evaluate.

Common situations: Page navigated or was redirected during the 2s wait, invalidating the evaluation context; browser automation driver version mismatch making evaluate return undefined; anti-bot script neutralizing injected scripts.

Related errors


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