jackwener/OpenCLI · error · AuthRequiredError('jimeng.jianying.com')

${probe.detail}

Error message

${probe.detail}

What it means

verifyJimengIdentity runs a WHOAMI_PROBE script inside the authenticated Jimeng page. When the probe reports kind 'auth', the user is not signed in to jimeng.jianying.com, so an AuthRequiredError is raised with the probe's detail, prompting the interactive login flow.

Source

Thrown at clis/jimeng/auth.js:28

const WHOAMI_PROBE = `(async () => {
  try {
    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. Open https://jimeng.jianying.com/ in the attached Chrome window and sign in, then retry
  2. Re-run the site's auth command (registerSiteAuthCommands login flow) to wait for login interactively
  3. Verify cookies for jimeng.jianying.com exist and are not expired
  4. If cookies are valid but the probe still fails, check whether Jimeng changed its whoami endpoint/response shape
  5. Clear stale cookies and log in again if the session is half-broken

Example fix

// before
await verifyJimengIdentity(page); // AuthRequiredError
// after
try {
  await verifyJimengIdentity(page);
} catch (err) {
  if (err instanceof AuthRequiredError) {
    console.error('Not signed in to Jimeng — run the login flow: open jimeng.jianying.com and sign in.');
  }
  throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('jimeng.jianying.com', 'Sign in first');

Type guard

function isJimengAuthError(err) {
  return err instanceof AuthRequiredError && err.message.includes('jimeng');
}

Try / catch

try {
  const identity = await verifyJimengIdentity(page);
} catch (err) {
  if (err instanceof AuthRequiredError) {
    await runJimengLoginFlow(); // interactive sign-in, then retry
    return verifyJimengIdentity(page);
  }
  throw err;
}

Prevention

When it happens

Trigger: page.evaluate(WHOAMI_PROBE) executes in the Jimeng page but the embedded whoami API call returns an auth error — i.e. no valid session cookies for jimeng.jianying.com in the attached Chrome profile, or the session expired.

Common situations: User never logged into Jimeng in the controlling Chrome instance; cookies cleared or expired; Jimeng invalidated the session server-side; using a fresh Chrome profile without login.

Related errors


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