jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

After the /mine/ probe, verifyDoubanIdentity only handles probe.kind 'auth' (AuthRequiredError), 'unknown' with a cookie-derived uid, and a successful probe. Any other unexpected probe shape (no user id, parse failed and no cookie uid, malformed result) is raised as a CommandExecutionError so the caller sees the raw probe JSON instead of a silent wrong identity.

Source

Thrown at clis/douban/auth.js:46

      const parseUid = (value) => String(value || '').match(/(?:^|\\/)people\\/(\\d+)\\/?/)?.[1] || '';
      const currentUrl = new URL(window.location.href);
      if (currentUrl.hostname === 'accounts.douban.com' || currentUrl.pathname.startsWith('/passport/')) {
        return { kind: 'auth', detail: 'Douban /mine redirected to the login flow' };
      }
      const navUser = document.querySelector('.nav-user-account .bn-more, .top-nav-info a.bn-more');
      const navHref = navUser?.getAttribute('href') || navUser?.href || '';
      const user_id = parseUid(window.location.href) || parseUid(navHref);
      const name = (navUser?.textContent || document.querySelector('.info h1, h1')?.textContent || '').trim();
      return user_id
        ? { ok: true, user_id, name }
        : { kind: 'unknown', detail: 'Douban user_id parse failed: href=' + navHref + ' location=' + window.location.href };
    })()
  `);
  if (probe?.kind === 'unknown' && cookieUid) {
    return { user_id: cookieUid, name: '' };
  }
  if (probe?.kind === 'auth') throw new AuthRequiredError('douban.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Douban probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'douban',
  domain: 'douban.com',
  loginUrl: 'https://accounts.douban.com/passport/login',
  columns: ['user_id', 'name'],
  quickCheck: hasDoubanSessionCookie,
  verify: verifyDoubanIdentity,
  poll: async (page) => {
    if (!await hasDoubanSessionCookie(page)) {
      throw new AuthRequiredError('douban.com', 'Waiting for Douban dbcl2 / ck cookies');
    }
    return verifyDoubanIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log in to douban.com in the reused browser so a valid session exists, then rerun
  2. Inspect the probe JSON in the error message to see which field was missing
  3. Update/patch the probe script if douban changed the /mine/ page structure
Defensive patterns

Strategy: try-catch

Validate before calling

if (!cookies.some(c => c.name === 'dbcl2')) console.warn('No dbcl2 fallback cookie; ensure /mine/ renders the user nav');

Type guard

function probeIsUsable(probe) { return probe && (probe.ok || (probe.kind === 'unknown' && probe.user_id)); }

Try / catch

try { return await verifyDoubanIdentity(page); } catch (e) { if (e instanceof CommandExecutionError && /Unexpected Douban probe/.test(e.message)) { console.error('Probe payload:', e.message, '— check douban /mine/ layout changes'); } throw e; }

Prevention

When it happens

Trigger: probe.ok is falsy or probe.user_id missing: /mine/ loaded but the page layout/href yielded no user id and no dbcl2 cookie existed to fall back on; probe evaluates to null/undefined.

Common situations: Douban DOM changes breaking the in-page parser; page failed to render /mine/ (error page) before evaluation; rare logged-out-but-unusual redirect state not classified as auth.

Related errors


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