jackwener/OpenCLI · error · CommandExecutionError
Unexpected Gitee probe: ${JSON.stringify(probe)}
Error message
Unexpected Gitee probe: ${JSON.stringify(probe)} What it means
The final guard in verifyGiteeIdentity (clis/gitee/auth.js): if the probe result is neither ok, auth, http, nor exception, it throws this CommandExecutionError with the JSON of the whole probe object. It means the WHOAMI_PROBE returned a shape the code does not recognize — a contract violation between the in-page script and the Node-side verification.
Source
Thrown at clis/gitee/auth.js:26
const r = await fetch('/api/v5/user', { credentials: 'include', headers: { Accept: 'application/json' } });
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Gitee /api/v5/user HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
if (!d || !d.id || !d.login) return { kind: 'auth', detail: 'Gitee /api/v5/user has no id/login — anonymous' };
return { ok: true, user_id: String(d.id), username: String(d.login), name: String(d.name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyGiteeIdentity(page) {
await page.goto('https://gitee.com/');
await page.wait(1);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('gitee.com', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Gitee /api/v5/user`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Gitee whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Gitee probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, username: probe.username, name: probe.name };
}
registerSiteAuthCommands({
site: 'gitee',
domain: 'gitee.com',
loginUrl: 'https://gitee.com/login',
columns: ['user_id', 'username', 'name'],
verify: verifyGiteeIdentity,
poll: async (page) => {
const probe = await page.evaluate(WHOAMI_PROBE);
if (!probe?.ok) throw new AuthRequiredError('gitee.com', 'Waiting for Gitee login');
return { user_id: probe.user_id, username: probe.username, name: probe.name };
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the JSON in the message: null/undefined usually means the page context died during evaluation.
- Re-navigate to https://gitee.com/ and retry; if it recurs, restart the browser/profile.
- Check for extensions or middleware injecting/rewriting page scripts on gitee.com.
- If you customized WHOAMI_PROBE, ensure it returns one of the documented kinds: auth, http, exception, or ok.
Example fix
// before — evaluating on a page that may have navigated away
const probe = await page.evaluate(WHOAMI_PROBE);
// after — validate probe shape before verify
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe == null) throw new Error('Probe returned null — page context lost'); Defensive patterns
Strategy: type-guard
Validate before calling
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe == null || typeof probe !== 'object' || !('kind' in probe || 'ok' in probe)) {
throw new Error('Probe shape invalid — page context likely lost');
} Type guard
function isWellFormedProbe(p) {
return p != null && typeof p === 'object' &&
(p.ok === true || ['auth', 'http', 'exception'].includes(p.kind));
} Try / catch
try {
const identity = await verifyGiteeIdentity(page);
} catch (err) {
if (err.message.startsWith('Unexpected Gitee probe:')) {
// parse the JSON payload in the message; re-navigate and retry once
} else throw err;
} Prevention
- Confirm the tab has not navigated/crashed before calling page.evaluate.
- Keep WHOAMI_PROBE unmodified and returning one of the documented kinds.
- Treat a null evaluate result as a page-context failure, not an auth problem.
- Log the full probe JSON (it is already embedded in the message) when diagnosing.
When it happens
Trigger: page.evaluate returns null/undefined (context destroyed or evaluation wrapper swallowed the result), the probe script was truncated/altered by page CSP or a rewriter, or a modified probe returns a new kind value not covered by the switch.
Common situations: The browser tab navigated or crashed so page.evaluate resolved to null; a proxy or injecting extension rewriting page scripts; a locally patched/custom probe returning an unexpected payload shape.
Related errors
- Unexpected Amazon probe: ${JSON.stringify(probe)}
- Booking.com extractor returned an invalid status
- Ctrip cruise DOM extraction returned malformed rows
- ${context} returned malformed browser output.
- Gitee whoami failed: ${probe.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1f25cdb003b7d6b4.
Report an issue: GitHub.