jackwener/OpenCLI · error · CommandExecutionError

Jimeng whoami failed: ${probe.detail}

Error message

Jimeng whoami failed: ${probe.detail}

What it means

If the WHOAMI_PROBE script itself throws while executing in the page (kind 'exception'), verifyJimengIdentity wraps it as CommandExecutionError('Jimeng whoami failed: <detail>'). The identity check could not even complete, indicating a scripting or page-state problem rather than an auth or HTTP issue.

Source

Thrown at clis/jimeng/auth.js:30

    const r = await fetch('/passport/account/info/v2/?aid=513695', { credentials: 'include', headers: { Accept: 'application/json' } });
    if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Jimeng passport HTTP ' + r.status };
    if (!r.ok) return { kind: 'http', httpStatus: r.status };
    const d = await r.json();
    const u = d && d.data;
    if (!u || !u.user_id || u.is_visitor_account) return { kind: 'auth', detail: 'Jimeng passport returned a visitor account (anonymous)' };
    return { ok: true, user_id: String(u.user_id_str || u.user_id), screen_name: String(u.screen_name || u.name || '') };
  } catch (e) {
    return { kind: 'exception', detail: String(e && e.message || e) };
  }
})()`;

async function verifyJimengIdentity(page) {
  await page.goto('https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0');
  await page.wait(2);
  const probe = await page.evaluate(WHOAMI_PROBE);
  if (probe?.kind === 'auth') throw new AuthRequiredError('jimeng.jianying.com', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jimeng passport`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Jimeng whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jimeng probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, screen_name: probe.screen_name };
}

registerSiteAuthCommands({
  site: 'jimeng',
  domain: 'jimeng.jianying.com',
  loginUrl: 'https://jimeng.jianying.com/',
  columns: ['user_id', 'screen_name'],
  verify: verifyJimengIdentity,
  poll: async (page) => {
    const probe = await page.evaluate(WHOAMI_PROBE);
    if (!probe?.ok) throw new AuthRequiredError('jimeng.jianying.com', 'Waiting for Jimeng login');
    return { user_id: probe.user_id, screen_name: probe.screen_name };
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reload the Jimeng page and ensure it fully loads before the probe runs (increase the wait after page.goto)
  2. Read probe.detail in the message for the underlying JS error
  3. Verify the page URL is jimeng.jianying.com (not a redirect/error page) before evaluating
  4. Update the CLI/WHOAMI_PROBE if Jimeng changed its page structure
  5. Disable extensions that inject scripts or block requests on the page

Example fix

// before
const probe = await page.evaluate(WHOAMI_PROBE);
// after
await page.goto('https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0');
await page.wait(5); // give SPA more time before probing
const probe = await page.evaluate(WHOAMI_PROBE);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!page.url().includes('jimeng.jianying.com')) throw new Error('Probe must run on jimeng.jianying.com — navigate first');

Type guard

function isProbeException(err) {
  return err instanceof CommandExecutionError && err.message.startsWith('Jimeng whoami failed:');
}

Try / catch

try {
  const identity = await verifyJimengIdentity(page);
} catch (err) {
  if (isProbeException(err)) {
    console.error('In-page probe crashed:', err.message); // inspect detail, reload page and retry
  }
  throw err;
}

Prevention

When it happens

Trigger: page.evaluate(WHOAMI_PROBE) rejects or the probe's try/catch returns kind 'exception' — e.g. the page failed to load fully, the probe references APIs removed from the page context, CSP blocks the fetch, or the page was navigated away mid-probe.

Common situations: Page still loading or redirected to another URL when the probe runs; Jimeng front-end update changing global objects the probe depends on; browser extension or CSP interfering; stale tab with an error page.

Related errors


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