{"record":{"id":"53e159da17bda5c9","repo":"jackwener/OpenCLI","slug":"wechat-channels-whoami-failed-probe-detail","errorCode":null,"errorMessage":"WeChat Channels whoami failed: ${probe.detail}","messagePattern":"WeChat Channels whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/wechat-channels/auth.js","lineNumber":44,"sourceCode":"      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      if (!d || d.base_resp?.ret !== 0) {\n        return { kind: 'auth', detail: 'WeChat Channels auth_data base_resp.ret=' + String(d?.base_resp?.ret) };\n      }\n      const fu = d.data?.finder_user || d.finder_user || {};\n      const userId = String(fu.uniq_id || fu.username || '');\n      const name = String(fu.nickname || fu.name || '');\n      if (!userId && !name) {\n        return { kind: 'auth', detail: 'WeChat Channels auth_data 200 but finder_user empty' };\n      }\n      return { ok: true, user_id: userId, name };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('channels.weixin.qq.com', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from auth_data`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`WeChat Channels whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected WeChat Channels probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'wechat-channels',\n  domain: 'channels.weixin.qq.com',\n  loginUrl: 'https://channels.weixin.qq.com/login.html?from=assistant',\n  columns: ['user_id', 'name'],\n  quickCheck: hasWechatChannelsSessionCookie,\n  verify: verifyWechatChannelsIdentity,\n  poll: async (page) => {\n    if (!await hasWechatChannelsSessionCookie(page)) {\n      throw new AuthRequiredError('channels.weixin.qq.com', 'Waiting for WeChat Channels sessionid cookie');\n    }\n    return verifyWechatChannelsIdentity(page);\n  },\n});","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/auth.js#L26-L62","documentation":"The probe's in-page async function caught an unexpected exception (kind:'exception') — e.g. fetch rejected, JSON parsing failed, or page context issues — and rethrows the detail wrapped in this CommandExecutionError. It means the whoami check could not complete, not necessarily that auth failed.","triggerScenarios":"fetch to auth_data rejects (network interruption, CORS, page navigating mid-probe); r.json() throws on a non-JSON response (error page/HTML); the page was redirected or closed during the 2s post-goto wait so the evaluate context is wrong.","commonSituations":"Flaky network or proxy injecting HTML error pages; the platform redirecting mid-probe; page navigation/refresh racing the evaluate; browser automation context destroyed.","solutions":["Read the detail string to see the underlying exception (e.g. 'Failed to fetch' vs JSON parse error).","Simply retry — transient network/page-load races often succeed on a second run.","Increase stability: ensure the page fully loads before verify (the fixed page.wait(2) may be too short on slow networks).","Re-login if the platform keeps redirecting during the probe.","Check for proxies/extensions altering responses to non-JSON."],"exampleFix":"// before (probe raced navigation)\nawait page.goto(url); await page.wait(2); const probe = await page.evaluate(...);\n// after\nawait page.goto(url, { waitUntil: 'networkidle' });\nconst probe = await page.evaluate(...);","handlingStrategy":"try-catch","validationCode":"// Ensure page is settled before probing\nawait page.goto('https://channels.weixin.qq.com/platform');\nawait page.wait(5); // longer than default 2s on slow networks","typeGuard":"function isExceptionProbe(p) { return p != null && p.kind === 'exception' && typeof p.detail === 'string'; }","tryCatchPattern":"try {\n  await verifyWechatChannelsIdentity(page);\n} catch (e) {\n  if (/whoami failed/.test(e.message)) {\n    await sleep(3000);\n    return verifyWechatChannelsIdentity(page); // transient races often clear\n  }\n  throw e;\n}","preventionTips":["Allow the platform page to fully load before verification","Retry transient 'Failed to fetch'/'JSON parse' details once","Avoid navigating or closing the page during the probe","Investigate proxies/extensions that inject non-JSON responses"],"tags":["exception","network","wechat","probe"],"backgroundTag":"unexpected-exception-in-probe","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}