jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

verifyJdIdentity throws CommandExecutionError('Unexpected JD probe: ...') when the in-page evaluate on home.jd.com returns a payload without ok:true and without kind:'auth' — an unrecognized probe result. This is a defensive guard against unexpected DOM/JS shapes rather than an auth problem.

Source

Thrown at clis/jd/auth.js:29

  if (!await hasJdSessionCookie(page)) {
    throw new AuthRequiredError('jd.com', 'JD pin / thor cookie missing');
  }
  await page.goto('https://home.jd.com/');
  await page.wait(3);
  const probe = await page.evaluate(`
    (() => {
      const pinCookie = (document.cookie.split('; ').find(c => c.startsWith('pin=')) || '').split('=')[1] || '';
      const decoded = pinCookie ? decodeURIComponent(pinCookie) : '';
      if (!decoded) {
        return { kind: 'auth', detail: 'JD pin cookie empty after decode' };
      }
      const nickEl = document.querySelector('.user-info, #aliveUserName, .name, .user-name');
      const nickname = (nickEl && nickEl.textContent && nickEl.textContent.trim()) || '';
      return { ok: true, pin: decoded, nickname };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('jd.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected JD probe: ${JSON.stringify(probe)}`);
  return { pin: probe.pin, nickname: probe.nickname };
}

registerSiteAuthCommands({
  site: 'jd',
  domain: 'jd.com',
  loginUrl: 'https://passport.jd.com/new/login.aspx',
  columns: ['pin', 'nickname'],
  quickCheck: hasJdSessionCookie,
  verify: verifyJdIdentity,
  poll: async (page) => {
    if (!await hasJdSessionCookie(page)) {
      throw new AuthRequiredError('jd.com', 'Waiting for JD pin / thor cookie');
    }
    return verifyJdIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command once — transient rendering failures often resolve
  2. Log in to JD and confirm home.jd.com shows your account normally in the browser
  3. Check for JD anti-bot/captcha pages and complete any challenge manually
  4. Update the opencli package in case JD changed its page structure (selector drift)

Example fix

// before
const me = await jdWhoami();
// after
try {
  const me = await jdWhoami();
} catch (e) {
  if (e.code === 'COMMAND_EXEC' && /Unexpected JD probe/.test(e.message)) {
    await sleep(3000); // let the page settle, then retry
    const me = await jdWhoami();
  }
}
Defensive patterns

Strategy: retry

Validate before calling

// ensure page settled before probing
await page.goto('https://home.jd.com/');
await page.waitForSelector('.user-info, #aliveUserName, .name, .user-name', { timeout: 10000 }).catch(() => {});

Type guard

function isUnexpectedProbe(e) {
  return e?.code === 'COMMAND_EXEC' && /Unexpected JD probe/.test(e.message);
}

Try / catch

for (let i = 0; i < 3; i++) {
  try { return await jdVerify(); }
  catch (e) { if (!isUnexpectedProbe(e) || i === 2) throw e; await sleep(3000); }
}

Prevention

When it happens

Trigger: The probe script's page.evaluate returns null/undefined (page failed to render), or returns an object lacking both ok and kind fields — e.g. JD changed its home page markup, an anti-bot interstitial replaced the page, or the page navigated away before evaluation.

Common situations: JD served a captcha/anti-bot page instead of home.jd.com; slow network left the page unrendered when evaluate ran; JD frontend redesign moved the .user-info/#aliveUserName selectors; iframe/embedded layout changes.

Related errors


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