jackwener/OpenCLI · error · CommandExecutionError

Unexpected Doubao probe: ${JSON.stringify(result)}

Error message

Unexpected Doubao probe: ${JSON.stringify(result)}

What it means

verifyDoubaoIdentity runs an in-page probe against Doubao's /passport/account/info endpoint and classifies the result as 'auth', 'http', or 'exception'. If the probe returns a result that is not ok and matches none of the known kinds, the function throws this CommandExecutionError as a catch-all. It indicates the in-page probe script returned an unexpected/unrecognized shape, so identity could not be verified.

Source

Thrown at clis/doubao/auth.js:39

      if (!res.ok) return { kind: 'http', httpStatus: res.status };
      const d = await res.json();
      const data = d && d.data;
      if (!data || !data.user_id_str) {
        return { kind: 'auth', detail: 'Doubao /passport/account/info returned no user_id_str' };
      }
      return {
        ok: true,
        user_id: String(data.user_id_str),
        name: String(data.name || data.screen_name || ''),
      };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('www.doubao.com', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /passport/account/info`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`Doubao whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected Doubao probe: ${JSON.stringify(result)}`);
  return { user_id: result.user_id, name: result.name };
}

registerSiteAuthCommands({
  site: 'doubao',
  domain: 'www.doubao.com',
  loginUrl: 'https://www.doubao.com/chat/',
  columns: ['user_id', 'name'],
  verify: verifyDoubaoIdentity,
  // passport_csrf_token is set for anonymous sessions too, so a cookie gate
  // would navigate away mid-login. Probe the account API on the current page
  // (no goto) and only confirm once a real user_id is present.
  poll: async (page) => {
    const loggedIn = await page.evaluate(`(async () => {
      try {
        const r = await fetch('/passport/account/info/v2/', { credentials: 'include', headers: { Accept: 'application/json' } });
        if (!r.ok) return false;
        const d = await r.json();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-login to www.doubao.com so the account-info endpoint returns a recognizable response
  2. Reload the Doubao tab and retry the command after the page fully loads
  3. Check for Doubao verification/captcha challenges and complete them in the browser
  4. Update the library to get probe-script fixes for the current Doubao site version

Example fix

// before
if (!result?.ok) throw new CommandExecutionError(`Unexpected Doubao probe: ${JSON.stringify(result)}`);
// after
if (!result?.ok) {
  if (result?.kind) throw new CommandExecutionError(`Doubao probe failed (${result.kind}): ${JSON.stringify(result)}`);
  throw new CommandExecutionError('Unexpected Doubao probe: page returned no account info; try reloading or re-authenticating');
}
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await page.evaluate(probeScript());
if (!res || typeof res !== 'object' || !['auth','http','exception'].includes(res.kind)) {
  throw new Error('Doubao probe returned unexpected shape: ' + JSON.stringify(res));
}

Type guard

function isProbeResult(r) {
  return !!r && typeof r === 'object' && ['auth','http','exception'].includes(r.kind) && typeof r.ok === 'boolean';
}

Try / catch

try {
  const identity = await verifyDoubaoIdentity(page);
} catch (e) {
  if (e instanceof AuthRequiredError) { await runLoginFlow(); }
  else if (/Unexpected Doubao probe/.test(e.message)) { await page.reload(); await runLoginFlow(); }
  else throw e;
}

Prevention

When it happens

Trigger: The page.evaluate probe returns {ok:false} or an object whose 'kind' is none of 'auth'|'http'|'exception', or result is null/undefined — e.g. Doubao changed the account-info response format, the probe script was interrupted, or an unknown result shape is produced.

Common situations: Doubao site DOM/API changes breaking the probe script; running against a redirected or partially loaded page; anti-bot interstitials altering the response; stale cookies producing unexpected payloads.

Related errors


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