{"record":{"id":"e77d36206b987079","repo":"jackwener/OpenCLI","slug":"probe-detail-e77d36","errorCode":null,"errorMessage":"${probe.detail}","messagePattern":"\\$\\{probe\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/wechat-channels/auth.js","lineNumber":42,"sourceCode":"        body: '{}',\n      });\n      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);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/auth.js#L24-L60","documentation":"After confirming the sessionid cookie, the tool navigates to the platform and runs an in-page probe. When the probe reports kind:'auth' (redirect to login.html, or auth_data returning base_resp.ret != 0, or empty finder_user), the detail is rethrown as an AuthRequiredError — the cookie exists but the server considers the session invalid.","triggerScenarios":"Cookie present but expired/revoked server-side (platform redirects to login.html); auth_data endpoint replies with non-zero base_resp.ret (e.g. ret 200013-type invalid-session codes); account lacks finder_user data so identity extraction fails.","commonSituations":"WeChat invalidated the session after password change or security check; session cookie present but CSRF/refresh tokens gone; logging in with an account that has no Channels (视频号) identity; risk-control flagging automated access.","solutions":["Re-run the login flow (login.html QR scan) to obtain a fresh session, then retry.","Check the detail string: base_resp.ret codes indicate server-side rejection — search the code or re-login.","Confirm the logged-in account actually has a Channels/视频号 identity.","Avoid rapid automated calls that may trigger risk-control; add delays between operations.","If a redirect to login.html persists despite fresh cookies, clear site cookies and log in again."],"exampleFix":"// before\nwechat-channels whoami   # sessionid exists but stale\n// after\nwechat-channels login    # refresh session via QR\nwechat-channels whoami","handlingStrategy":"retry","validationCode":"// After goto, confirm we weren't bounced to login before probing\nawait page.goto('https://channels.weixin.qq.com/platform');\nif (/login\\.html/.test(await page.evaluate('location.href'))) {\n  await runLoginFlow(); // re-auth before calling verify\n}","typeGuard":"function isAuthProbe(p) { return p != null && (p.ok === true || p.kind === 'auth' || p.kind === 'http' || p.kind === 'exception'); }","tryCatchPattern":"try {\n  const identity = await verifyWechatChannelsIdentity(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    await runLoginFlow();      // refresh session via QR\n    identity = await verifyWechatChannelsIdentity(page);\n  } else throw e;\n}","preventionTips":["Treat any AuthRequiredError from verify as 're-login needed' and automate the QR flow","Avoid rapid automated calls that trigger risk-control invalidation","Verify the account actually has a Channels (视频号) identity","Re-login after WeChat password changes or security events"],"tags":["auth","wechat","session-expired","cookies"],"backgroundTag":"auth-required-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}