jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

Final sanity check in verifyJimengIdentity: when the probe result is neither an auth/http/exception kind nor ok, the code throws CommandExecutionError with the JSON-serialized probe. This captures any unrecognized probe outcome so unknown protocol changes surface loudly instead of silently returning bad identity data.

Source

Thrown at clis/jimeng/auth.js:31

    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. Read the JSON in the message to see the actual probe shape returned
  2. Compare with WHOAMI_PROBE's expected contract and update the probe for Jimeng's current response format
  3. Ensure the probe returns only serializable values from page.evaluate
  4. Check for Jimeng A/B tests or regional variants that return a different whoami response
  5. Update the CLI to a version matching the current Jimeng page behavior

Example fix

// before
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jimeng probe: ${JSON.stringify(probe)}`);
// after
if (!probe?.ok) {
  if (probe?.pending) return null; // tolerate newly-seen intermediate state
  throw new CommandExecutionError(`Unexpected Jimeng probe: ${JSON.stringify(probe)}`);
}
Defensive patterns

Strategy: type-guard

Type guard

function isUsableProbe(probe) {
  return probe != null && typeof probe === 'object' && probe.ok === true &&
    typeof probe.user_id === 'string' && typeof probe.screen_name === 'string';
}

Try / catch

try {
  const identity = await verifyJimengIdentity(page);
} catch (err) {
  if (/Unexpected Jimeng probe/.test(err.message)) {
    const raw = err.message.slice('Unexpected Jimeng probe: '.length);
    console.error('Probe contract mismatch:', JSON.parse(raw)); // diagnose and update WHOAMI_PROBE
  }
  throw err;
}

Prevention

When it happens

Trigger: WHOAMI_PROBE returns an object without ok:true and without one of the known kinds — e.g. Jimeng changed the probe's response contract, the probe returned null/undefined, or a partially failing result with new fields.

Common situations: Jimeng front-end/API updated so the probe's assumptions broke; probe returns undefined because evaluate serialization failed (non-serializable return); a new intermediate result kind introduced by a code change.

Related errors


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