{"record":{"id":"81149516b63147d2","repo":"jackwener/OpenCLI","slug":"auth-811495","errorCode":null,"errorMessage":"auth","messagePattern":"auth","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/hupu/auth.js","lineNumber":29,"sourceCode":"    throw new AuthRequiredError('hupu.com', 'Hupu u cookie missing — anonymous');\n  }\n  await page.goto('https://my.hupu.com/');\n  await page.wait(2);\n  const probe = await page.evaluate(`\n    (() => {\n      if (/passport\\\\.hupu\\\\.com\\\\/.*login/.test(location.href)) {\n        return { kind: 'auth', detail: 'Hupu my page redirected to passport login' };\n      }\n      const uCookie = (document.cookie.split('; ').find(c => c.startsWith('u=')) || '').split('=')[1] || '';\n      const el = document.querySelector('.user-name, .username, .nick, [class*=\"userName\"]');\n      const username = (el?.innerText || '').trim();\n      if (!uCookie) {\n        return { kind: 'auth', detail: 'Hupu my page rendered but u cookie absent — stale session' };\n      }\n      return { ok: true, user_id: uCookie, username };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('hupu.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, username: probe.username };\n}\n\nregisterSiteAuthCommands({\n  site: 'hupu',\n  domain: 'hupu.com',\n  loginUrl: 'https://passport.hupu.com/pc/login',\n  columns: ['user_id', 'username'],\n  quickCheck: hasHupuUserCookie,\n  verify: verifyHupuIdentity,\n  poll: async (page) => {\n    if (!await hasHupuUserCookie(page)) {\n      throw new AuthRequiredError('hupu.com', 'Waiting for Hupu u cookie');\n    }\n    return verifyHupuIdentity(page);\n  },\n});","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/auth.js#L11-L47","documentation":"The in-page probe on my.hupu.com returned { kind: 'auth', ... }, meaning the page rendered but the 'u' cookie was absent — a stale/expired session. verifyHupuIdentity converts that into AuthRequiredError('hupu.com', detail).","triggerScenarios":"The first cookie check passed (or raced), but after page.goto('https://my.hupu.com/') the session proved invalid: no u cookie in the page context, or the page redirected to passport.hupu.com login.","commonSituations":"Session expired between commands; server-side session revoked while the cookie still existed; intermittent redirect to the login page; clock/token expiry on Hupu's side.","solutions":["Re-login to hupu.com in the browser session and rerun identity verification","Delete stale cookies and perform a clean login","Check the probe detail message to confirm the stale-session diagnosis","If redirects to passport.hupu.com occur, complete the login flow before calling verify"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isAuthProbe = p => p && typeof p === 'object' && p.kind === 'auth';","tryCatchPattern":"try { const identity = await verifyHupuIdentity(page); } catch (e) { if (e instanceof AuthRequiredError && /stale session/.test(e.detail ?? e.message)) { await clearCookiesAndLogin(page); return verifyHupuIdentity(page); } throw e; }","preventionTips":["Treat 'u' cookie presence as necessary but not sufficient — expect server-side expiry","Re-login when commands fail after long idle periods","Perform a full login flow if my.hupu.com redirects to passport.hupu.com","Keep sessions active with periodic verification instead of one-shot checks"],"tags":["auth","session-expired","cookies"],"backgroundTag":"stale-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}