jackwener/OpenCLI · warning · CommandExecutionError
Unexpected Maimai probe: ${JSON.stringify(probe)}
Error message
Unexpected Maimai probe: ${JSON.stringify(probe)} What it means
Fallback error at clis/maimai/auth.js:36: thrown when the probe result is neither auth/http/exception nor a successful ok:true result. The message JSON-stringifies the whole probe for debugging. It guards against unexpected probe shapes — e.g. undefined, null, or an object from a mismatched/older probe implementation.
Source
Thrown at clis/maimai/auth.js:36
return {
ok: true,
user_id: String(user.id),
name: String(user.name || ''),
company: String(user.company || ''),
};
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyMaimaiIdentity(page) {
await page.goto('https://maimai.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('maimai.cn', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Maimai`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Maimai whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Maimai probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name, company: probe.company };
}
registerSiteAuthCommands({
site: 'maimai',
domain: 'maimai.cn',
loginUrl: 'https://maimai.cn/',
columns: ['user_id', 'name', 'company'],
verify: verifyMaimaiIdentity,
poll: verifyMaimaiIdentity,
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the JSON in the message to see what the probe actually returned
- Confirm the browser context is the maimai.cn tab and evaluate ran (log the raw probe)
- Re-run with an unmodified WHOAMI_PROBE to rule out contract drift
- Update the CLI/driver if page.evaluate return serialization changed with a browser upgrade
Example fix
// before
const probe = await page.evaluate(WHOAMI_PROBE);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Maimai probe: ${JSON.stringify(probe)}`);
// after
const probe = await page.evaluate(WHOAMI_PROBE);
console.debug('probe:', probe);
if (probe === undefined) throw new Error('page.evaluate returned undefined — check browser context'); Defensive patterns
Strategy: type-guard
Type guard
function isValidProbe(p) {
return p != null && typeof p === 'object' &&
(p.ok === true || ['auth', 'http', 'exception'].includes(p.kind));
} Try / catch
try {
await verifyMaimaiIdentity(page);
} catch (e) {
if (/Unexpected Maimai probe/.test(e.message)) {
console.error(e.message); // includes full probe JSON for diagnosis
console.error('Check that the browser context is the maimai.cn tab and the probe script is unmodified');
}
throw e;
} Prevention
- Log the raw probe result before asserting on it
- Never modify WHOAMI_PROBE's return shape without updating all branches
- Confirm evaluate targets the maimai.cn page, not another tab/frame
- Pin browser/driver versions to avoid evaluate serialization changes
When it happens
Trigger: page.evaluate returns undefined/null (script didn't evaluate, wrong browser context), or returns an object lacking kind and ok — e.g. a probe/evaluate contract mismatch after refactoring, or the evaluate layer serializing the async IIFE incorrectly.
Common situations: Running against a modified WHOAMI_PROBE that returns a new shape; evaluate() failing silently and returning undefined; driver/browser version changes altering evaluate return behavior; attaching to the wrong page/frame.
Related errors
- Unexpected Amazon probe: ${JSON.stringify(probe)}
- Unexpected Gitee probe: ${JSON.stringify(probe)}
- Unexpected Hupu probe: ${JSON.stringify(probe)}
- Unexpected Linux.do probe: ${JSON.stringify(probe)}
- Unexpected Quark probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d1119ea0f690b486.
Report an issue: GitHub.