jackwener/OpenCLI · error · CommandExecutionError
Unexpected Qwen probe: ${JSON.stringify(result)}
Error message
Unexpected Qwen probe: ${JSON.stringify(result)} What it means
After running the Qwen whoami probe, verifyQwenIdentity expects exactly one of four result shapes: kind='auth', kind='http', kind='exception', or a result with ok=true. Any other shape (e.g. ok=false with no kind, undefined/null result, malformed object) hits this fallback at clis/qwen/auth.js:39 and throws a CommandExecutionError embedding the JSON of the result.
Source
Thrown at clis/qwen/auth.js:39
const token = ${JSON.stringify(token)};
const res = await fetch('/api/v1/auths/', { credentials: 'include', headers: { 'Authorization': 'Bearer ' + token, 'Accept': 'application/json' } });
if (res.status === 401 || res.status === 403) {
return { kind: 'auth', detail: 'Qwen /api/v1/auths/ HTTP ' + res.status };
}
if (!res.ok) return { kind: 'http', httpStatus: res.status };
const d = await res.json();
if (!d || !d.id) {
return { kind: 'auth', detail: 'Qwen /api/v1/auths/ returned no user id' };
}
return { ok: true, user_id: String(d.id), name: String(d.name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') throw new AuthRequiredError('qwen.ai', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/v1/auths/`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Qwen whoami failed: ${result.detail}`);
if (!result?.ok) throw new CommandExecutionError(`Unexpected Qwen probe: ${JSON.stringify(result)}`);
return { user_id: result.user_id, name: result.name };
}
registerSiteAuthCommands({
site: 'qwen',
domain: 'qwen.ai',
loginUrl: 'https://chat.qwen.ai/auth?action=login',
columns: ['user_id', 'name'],
quickCheck: hasQwenSessionCookie,
verify: verifyQwenIdentity,
poll: async (page) => {
if (!await hasQwenSessionCookie(page)) {
throw new AuthRequiredError('qwen.ai', 'Waiting for Qwen token cookie');
}
return verifyQwenIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the JSON in the message: if ok=false, treat it as an auth failure and re-login with `qwen auth login`.
- Clear Qwen cookies/session state and log in again to remove stale responses.
- Upgrade the CLI to a version whose probe matches the current qwen.ai API.
- Report/patch the probe so every non-ok result is classified as auth/http/exception.
Example fix
// probe contract fix
return { kind: 'http', httpStatus: res.status }; // instead of bare { ok: false, status }
// caller
if (!result?.ok) throw new CommandExecutionError(`Unexpected Qwen probe: ${JSON.stringify(result)}`); Defensive patterns
Strategy: type-guard
Validate before calling
// pre-call sanity
if (result === undefined || result === null) {
throw new Error('Qwen probe returned no result');
} Type guard
function hasKnownShape(r) {
return !!r && typeof r === 'object' &&
('kind' in r ? ['auth','http','exception'].includes(r.kind) : r.ok === true);
} Try / catch
try {
const identity = await verifyQwenIdentity(page);
} catch (e) {
if (/Unexpected Qwen probe:/i.test(e.message)) {
const payload = JSON.parse(e.message.replace(/^Unexpected Qwen probe: /, ''));
if (payload && payload.ok === false) return relogin(); // treat as stale auth
}
throw e;
} Prevention
- Re-login whenever the embedded JSON shows ok:false — it usually means stale session state.
- Keep the CLI updated; probe result contracts break when qwen.ai changes its API.
- Wrap probe calls so unclassified results are logged for debugging before rethrow.
- Avoid manually editing probe scripts; use the maintained version.
When it happens
Trigger: The inline probe returns {ok:false,...} without a kind field, returns undefined/null, or returns an object with unexpected fields; any call path through verifyQwenIdentity where the probe contract is violated.
Common situations: Qwen frontend/API changed so the probe's response parsing returns ok:false without classifying the failure; stale cookies causing a silent non-JSON response the probe mishandles; a CLI version mismatch between the probe script and its result parser.
Related errors
- Qwen whoami failed: ${result.detail}
- Booking.com extractor returned an invalid status
- Ctrip cruise DOM extraction returned malformed rows
- Ctrip flight API returned HTTP ${status}; complete any verif
- ${context} returned malformed browser output.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3a36a1746a0ae2e5.
Report an issue: GitHub.