jackwener/OpenCLI · error · AuthRequiredError

my.hupu.com

Error message

my.hupu.com

What it means

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.

Source

Thrown at clis/hupu/mentions.js:134

            data: {
              items: items.slice(0, limit),
              hasNextPage,
              pageStr: nextPageStr
            }
          };
        } catch (error) {
          return {
            ok: false,
            error: error instanceof Error ? error.message : String(error)
          };
        }
      })()
    `);
        if (!result || typeof result !== 'object') {
            throw new CommandExecutionError('Read Hupu mentions failed: invalid browser response');
        }
        if (result.status === 401 || result.status === 403) {
            throw new AuthRequiredError('my.hupu.com', 'Read Hupu mentions failed: please log in to Hupu first');
        }
        if (!result.ok) {
            throw new CommandExecutionError(`Read Hupu mentions failed: ${result.error || 'unknown error'}`);
        }
        const items = result.data?.items || [];
        return items.map((item) => {
            const tid = item.tid ? String(item.tid) : '';
            const pid = item.pid ? String(item.pid) : '';
            return {
                time: item.publishTime || '',
                username: item.username || '',
                thread_title: item.threadTitle || '',
                post_content: stripHtml(item.postContent || ''),
                quote_content: stripHtml(item.quoteContent || ''),
                url: tid ? `https://bbs.hupu.com/${tid}.html` : '',
                reply_url: tid && pid ? `https://bbs.hupu.com/${tid}.html?pid=${pid}` : '',
                tid,
                pid,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open my.hupu.com in the browser used by the CLI and log in to Hupu, then rerun the command.
  2. Verify cookies for my.hupu.com exist and are current in the browser profile (Strategy.COOKIE depends on them).
  3. If 403 persists despite login, check for network/proxy/region restrictions on my.hupu.com.
  4. Re-run after clearing stale cookies and logging in again if the session keeps being rejected.

Example fix

// before (not logged in)
$ opencli hupu mentions
AuthRequiredError: Read Hupu mentions failed: please log in to Hupu first

// after: log in via the browser profile first
$ opencli browser open https://my.hupu.com  # log in manually
$ opencli hupu mentions  # now returns items
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure a logged-in Hupu session exists before running
const cookies = await browserContext.cookies('https://my.hupu.com');
if (!cookies.some(c => c.name && c.value && !c.expires || c.expires === -1 || c.expires > Date.now()/1000)) {
  throw new Error('Not logged in to my.hupu.com — log in first (hupu mentions requires auth)');
}

Type guard

function isAuthRequiredError(e) {
  return e instanceof Error && e.name === 'AuthRequiredError';
}

Try / catch

try {
  const mentions = await run('hupu mentions');
} catch (e) {
  if (isAuthRequiredError(e)) {
    console.error('Please log in to Hupu at my.hupu.com, then retry.');
  } else throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/9ea063a5abe92646. Report an issue: GitHub.