{"record":{"id":"02f23d188092a958","repo":"jackwener/OpenCLI","slug":"qwen-whoami-failed-result-detail","errorCode":null,"errorMessage":"Qwen whoami failed: ${result.detail}","messagePattern":"Qwen whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/auth.js","lineNumber":38,"sourceCode":"    try {\n      const token = ${JSON.stringify(token)};\n      const res = await fetch('/api/v1/auths/', { credentials: 'include', headers: { 'Authorization': 'Bearer ' + token, 'Accept': 'application/json' } });\n      if (res.status === 401 || res.status === 403) {\n        return { kind: 'auth', detail: 'Qwen /api/v1/auths/ HTTP ' + res.status };\n      }\n      if (!res.ok) return { kind: 'http', httpStatus: res.status };\n      const d = await res.json();\n      if (!d || !d.id) {\n        return { kind: 'auth', detail: 'Qwen /api/v1/auths/ returned no user id' };\n      }\n      return { ok: true, user_id: String(d.id), name: String(d.name || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('qwen.ai', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/v1/auths/`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Qwen whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Qwen probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'qwen',\n  domain: 'qwen.ai',\n  loginUrl: 'https://chat.qwen.ai/auth?action=login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasQwenSessionCookie,\n  verify: verifyQwenIdentity,\n  poll: async (page) => {\n    if (!await hasQwenSessionCookie(page)) {\n      throw new AuthRequiredError('qwen.ai', 'Waiting for Qwen token cookie');\n    }\n    return verifyQwenIdentity(page);\n  },\n});","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/auth.js#L20-L56","documentation":"verifyQwenIdentity runs an inline browser-side whoami probe against Qwen's /api/v1/auths/ endpoint. If the probe script itself throws (network crash, page closed, CSP, JS error inside the probe), it returns {kind:'exception'} and this CommandExecutionError surfaces the raw exception message. It means the identity check could not be completed, not that the user is logged out (that path throws AuthRequiredError instead).","triggerScenarios":"The inline node/browser probe passed to an execution helper throws any exception; verifyQwenIdentity catches it, packages it as result.kind='exception' with detail=String(e.message||e), and the check at clis/qwen/auth.js:38 rethrows it as `Qwen whoami failed: <detail>`.","commonSituations":"Browser context crashed or page navigated mid-probe; fetch to qwen.ai blocked by network/VPN/proxy or CORS; TLS interception; Qwen frontend changed so the probe script references a missing global; running headless without the Qwen page loaded.","solutions":["Read result.detail in the message and fix the underlying exception it names (DNS, proxy, TLS, page closed).","Re-run the command with network access to qwen.ai ensured; disable VPN/proxy or set proxy env vars.","Re-login via `qwen auth login` to restore a fresh page/context, then retry whoami.","Update the CLI; if Qwen changed its frontend, the inline probe may need a newer version."],"exampleFix":"// before\nconst result = await page.evaluate(probeScript); // throws -> kind:'exception'\n// after\ntry {\n  const result = await page.evaluate(probeScript);\n} catch (e) {\n  return { kind: 'exception', detail: String(e && e.message || e) }; // detail now tells you the real cause\n}","handlingStrategy":"try-catch","validationCode":"// before calling\nconst ok = typeof navigator !== 'undefined' || (page && !page.isClosed?.());\nif (!ok) throw new Error('Browser page unavailable for Qwen probe');","typeGuard":"function isProbeResult(r) {\n  return r !== null && typeof r === 'object' &&\n    (r.kind === 'auth' || r.kind === 'http' || r.kind === 'exception' || r.ok === true);\n}","tryCatchPattern":"try {\n  const user = await verifyQwenIdentity(page);\n} catch (e) {\n  if (String(e.message).startsWith('Qwen whoami failed:')) {\n    // inspect detail after the prefix; check network/proxy, restart browser, retry once\n  } else throw e;\n}","preventionTips":["Ensure stable network access to qwen.ai (no VPN/proxy blocking) before auth commands.","Keep the browser page alive; don't close/navigate it during identity checks.","Pin/upgrade CLI versions so the inline probe matches current Qwen frontend.","Catch CommandExecutionError with the 'Qwen whoami failed:' prefix separately from AuthRequiredError."],"tags":["network","auth","browser-automation","qwen"],"backgroundTag":"whoami-probe-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}