jackwener/OpenCLI · error · CommandExecutionError
Unexpected V2EX probe: ${JSON.stringify(probe)}
Error message
Unexpected V2EX probe: ${JSON.stringify(probe)} What it means
After the auth-specific check, verifyV2exIdentity throws CommandExecutionError('Unexpected V2EX probe: ...') when the in-page probe returns something that is neither {kind:'auth'} nor {ok:true}. This is a defensive guard: the probe script is only expected to produce those two shapes, so any other result (null, undefined, or an object with different keys) means the DOM probe failed or the evaluate bridge returned malformed data.
Source
Thrown at clis/v2ex/auth.js:27
async function verifyV2exIdentity(page) {
if (!await hasV2exAuthCookie(page)) {
throw new AuthRequiredError('v2ex.com', 'V2EX A2 session cookie missing — anonymous');
}
await page.goto('https://www.v2ex.com/');
await page.wait(1);
const probe = await page.evaluate(`
(() => {
const link = document.querySelector('#Top a[href^="/member/"]');
if (!link) return { kind: 'auth', detail: 'V2EX top bar has no member link — anonymous session' };
const href = link.getAttribute('href') || '';
const username = (link.innerText || href.replace('/member/', '')).trim();
if (!username) return { kind: 'auth', detail: 'V2EX member link present but username empty' };
return { ok: true, username };
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('v2ex.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected V2EX probe: ${JSON.stringify(probe)}`);
return { username: probe.username };
}
registerSiteAuthCommands({
site: 'v2ex',
domain: 'v2ex.com',
loginUrl: 'https://www.v2ex.com/signin',
columns: ['username'],
quickCheck: hasV2exAuthCookie,
verify: verifyV2exIdentity,
poll: async (page) => {
if (!await hasV2exAuthCookie(page)) {
throw new AuthRequiredError('v2ex.com', 'Waiting for V2EX A2 session cookie');
}
return verifyV2exIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the JSON in the message (it contains the actual probe value) to see whether the probe was null/undefined or an unexpected object.
- Retry after waiting for the page to fully load (add page.wait or a readiness check before evaluate).
- Ensure the browser page stays open and no navigation occurs during the probe; rerun the command.
- Manually load v2ex.com in the automation browser to clear any Cloudflare challenge, then retry.
- If V2EX's markup changed, update the probe script in clis/v2ex/auth.js to match the new DOM and return the expected {ok:true, username} shape.
Example fix
// before
const probe = await page.evaluate(`(() => { ... })()`);
// after: guard against undefined/empty DOM before probing
await page.goto('https://www.v2ex.com/');
await page.wait(2); // let top bar render
const probe = await page.evaluate(`(() => { ... })()`); Defensive patterns
Strategy: type-guard
Validate before calling
await page.goto('https://www.v2ex.com/');
await page.wait(2); // ensure top bar rendered before probing
if (page.isClosed()) throw new Error('Page closed before V2EX identity probe'); Type guard
function isOkProbe(p) {
return !!p && typeof p === 'object' && p.ok === true && typeof p.username === 'string' && p.username.length > 0;
} Try / catch
const probe = await page.evaluate(probeScript);
if (!isOkProbe(probe) && !(probe && probe.kind === 'auth')) {
// retry once after a wait, then fail with the JSON detail
} Prevention
- Wait for page readiness (top bar rendered) before evaluating the probe script.
- Avoid navigating or closing the page concurrently with the evaluate call.
- Log the raw probe value on failure — the JSON in the message reveals the actual shape.
- Clear Cloudflare challenges before running DOM probes against v2ex.com.
When it happens
Trigger: page.evaluate returns null/undefined (script evaluation failed, navigation destroyed the page context, or the evaluate bridge returned non-JSON), or returns an object lacking both kind:'auth' and ok:true — e.g. V2EX served a challenge/error page with unexpected markup that still matched '#Top a[href^="/member/"]' but with a usable username missing under a changed structure.
Common situations: Page navigated or was closed during evaluate; Cloudflare interstitial captured mid-load; opencli evaluate helper returned undefined for an IIFE string; V2EX layout change produced an unexpected probe result shape.
Related errors
- Unexpected Amazon probe: ${JSON.stringify(probe)}
- Unexpected Douban probe: ${JSON.stringify(probe)}
- Unexpected Gitee probe: ${JSON.stringify(probe)}
- Unexpected Hupu probe: ${JSON.stringify(probe)}
- Unexpected Linux.do probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3f83e81d67725755.
Report an issue: GitHub.