{"record":{"id":"7fcb19e4894fa991","repo":"jackwener/OpenCLI","slug":"unexpected-hupu-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Hupu probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Hupu probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hupu/auth.js","lineNumber":30,"sourceCode":"  }\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});\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/auth.js#L12-L48","documentation":"verifyHupuIdentity evaluates an in-page probe script that inspects the Hupu session (u cookie on the 'my page'). A probe result of {kind:'auth'} is mapped to AuthRequiredError, and anything else without ok:true reaches this CommandExecutionError. It means the probe returned an unrecognized shape (e.g. a thrown browser error serialized as {error} or unexpected null), so the library cannot classify the session state.","triggerScenarios":"The page.evaluate probe in verifyHupuIdentity returns null/undefined, or an object lacking ok/kind fields — typically when the in-page script throws and the error is swallowed into a non-standard result, or the Hupu 'my page' redirects somewhere unexpected so the probe code never runs as intended.","commonSituations":"Hupu changes the my-page URL or markup so the probe script crashes; navigation interrupted mid-evaluate; hupu.com serves a captcha/anti-bot interstitial instead of the expected page; the CLI's browser session is closed or navigated concurrently.","solutions":["Open the login flow (`hupu login` equivalent) to establish a fresh session, then retry the command","Log the full probe JSON to see the actual shape and compare with expected {ok:true,user_id,username} or {kind:'auth'}","Clear Hupu cookies and re-authenticate — a corrupted cookie set can make the probe script fail","Check for Hupu site changes (redirects, captcha walls) and update the probe script in clis/hupu/auth.js"],"exampleFix":"// before\nif (!probe?.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);\n// after\nif (!probe) throw new CommandExecutionError('Hupu probe returned no result — page may have failed to load');\nif (probe.error) throw new CommandExecutionError(`Hupu probe failed: ${probe.error}`);\nif (!probe.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);","handlingStrategy":"try-catch","validationCode":"const cookies = await page.context().cookies('https://hupu.com');\nif (!cookies.some(c => c.name === 'u')) await runHupuLogin(page);","typeGuard":"function isProbeOk(p) {\n  return !!p && typeof p === 'object' && p.ok === true && typeof p.user_id === 'string';\n}","tryCatchPattern":"try {\n  const identity = await verifyHupuIdentity(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError) await relogin();\n  else if (/Unexpected Hupu probe/.test(e.message)) await retryWithFreshPage(page);\n  else throw e;\n}","preventionTips":["Keep the Hupu session fresh; re-login before long-running jobs","Log the full probe payload on failure to diagnose new probe shapes quickly","Check for Hupu captcha/anti-bot interstitials before running verify","Update the probe script whenever Hupu changes the my-page URL or markup"],"tags":["auth","browser-automation","hupu","unexpected-state"],"backgroundTag":"unexpected-probe-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}