{"record":{"id":"9ea063a5abe92646","repo":"jackwener/OpenCLI","slug":"my-hupu-com","errorCode":null,"errorMessage":"my.hupu.com","messagePattern":"my\\.hupu\\.com","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/hupu/mentions.js","lineNumber":134,"sourceCode":"            data: {\n              items: items.slice(0, limit),\n              hasNextPage,\n              pageStr: nextPageStr\n            }\n          };\n        } catch (error) {\n          return {\n            ok: false,\n            error: error instanceof Error ? error.message : String(error)\n          };\n        }\n      })()\n    `);\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('Read Hupu mentions failed: invalid browser response');\n        }\n        if (result.status === 401 || result.status === 403) {\n            throw new AuthRequiredError('my.hupu.com', 'Read Hupu mentions failed: please log in to Hupu first');\n        }\n        if (!result.ok) {\n            throw new CommandExecutionError(`Read Hupu mentions failed: ${result.error || 'unknown error'}`);\n        }\n        const items = result.data?.items || [];\n        return items.map((item) => {\n            const tid = item.tid ? String(item.tid) : '';\n            const pid = item.pid ? String(item.pid) : '';\n            return {\n                time: item.publishTime || '',\n                username: item.username || '',\n                thread_title: item.threadTitle || '',\n                post_content: stripHtml(item.postContent || ''),\n                quote_content: stripHtml(item.quoteContent || ''),\n                url: tid ? `https://bbs.hupu.com/${tid}.html` : '',\n                reply_url: tid && pid ? `https://bbs.hupu.com/${tid}.html?pid=${pid}` : '',\n                tid,\n                pid,","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/mentions.js#L116-L152","documentation":"AuthRequiredError is thrown by the hupu mentions CLI when the in-page fetch of my.hupu.com/pcmapi/pc/space/v1/getMentionedRemindList returns HTTP 401 or 403, meaning the browser session has no valid Hupu login. The command uses Strategy.COOKIE and reads 'mentions/echoed me' notifications, which require authenticated cookies. The library throws this so the caller knows to log in to Hupu in the browser before retrying.","triggerScenarios":"Running the 'hupu mentions' command while the browser session for my.hupu.com is not logged in, has expired cookies, or the session cookie was rejected by the server (401/403 response captured inside the page.evaluate fetch loop).","commonSituations":"Users never logged into hupu.com in the automated browser profile; cookies expired after Hupu rotated sessions; using a clean/new browser profile; a corporate proxy or region block returning 403; logging out on another device invalidating the cookie.","solutions":["Open my.hupu.com in the browser used by the CLI and log in to Hupu, then rerun the command.","Verify cookies for my.hupu.com exist and are current in the browser profile (Strategy.COOKIE depends on them).","If 403 persists despite login, check for network/proxy/region restrictions on my.hupu.com.","Re-run after clearing stale cookies and logging in again if the session keeps being rejected."],"exampleFix":"// before (not logged in)\n$ opencli hupu mentions\nAuthRequiredError: Read Hupu mentions failed: please log in to Hupu first\n\n// after: log in via the browser profile first\n$ opencli browser open https://my.hupu.com  # log in manually\n$ opencli hupu mentions  # now returns items","handlingStrategy":"try-catch","validationCode":"// Ensure a logged-in Hupu session exists before running\nconst cookies = await browserContext.cookies('https://my.hupu.com');\nif (!cookies.some(c => c.name && c.value && !c.expires || c.expires === -1 || c.expires > Date.now()/1000)) {\n  throw new Error('Not logged in to my.hupu.com — log in first (hupu mentions requires auth)');\n}","typeGuard":"function isAuthRequiredError(e) {\n  return e instanceof Error && e.name === 'AuthRequiredError';\n}","tryCatchPattern":"try {\n  const mentions = await run('hupu mentions');\n} catch (e) {\n  if (isAuthRequiredError(e)) {\n    console.error('Please log in to Hupu at my.hupu.com, then retry.');\n  } else throw e;\n}","preventionTips":["Log in to my.hupu.com in the CLI's browser profile before running auth-required commands.","Periodically re-login; Hupu sessions expire and rotate cookies.","Keep a dedicated, persistent browser profile for the CLI so cookies survive restarts.","Check for AuthRequiredError first in catch blocks to give users a clear 'log in' message."],"tags":["auth","hupu","cookie","login-required"],"backgroundTag":"auth-required-login-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}