jackwener/OpenCLI · error · CommandExecutionError

Unexpected Hupu probe: ${JSON.stringify(probe)}

Error message

Unexpected Hupu probe: ${JSON.stringify(probe)}

What it means

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.

Source

Thrown at clis/hupu/auth.js:30

  }
  await page.goto('https://my.hupu.com/');
  await page.wait(2);
  const probe = await page.evaluate(`
    (() => {
      if (/passport\\.hupu\\.com\\/.*login/.test(location.href)) {
        return { kind: 'auth', detail: 'Hupu my page redirected to passport login' };
      }
      const uCookie = (document.cookie.split('; ').find(c => c.startsWith('u=')) || '').split('=')[1] || '';
      const el = document.querySelector('.user-name, .username, .nick, [class*="userName"]');
      const username = (el?.innerText || '').trim();
      if (!uCookie) {
        return { kind: 'auth', detail: 'Hupu my page rendered but u cookie absent — stale session' };
      }
      return { ok: true, user_id: uCookie, username };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('hupu.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, username: probe.username };
}

registerSiteAuthCommands({
  site: 'hupu',
  domain: 'hupu.com',
  loginUrl: 'https://passport.hupu.com/pc/login',
  columns: ['user_id', 'username'],
  quickCheck: hasHupuUserCookie,
  verify: verifyHupuIdentity,
  poll: async (page) => {
    if (!await hasHupuUserCookie(page)) {
      throw new AuthRequiredError('hupu.com', 'Waiting for Hupu u cookie');
    }
    return verifyHupuIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the login flow (`hupu login` equivalent) to establish a fresh session, then retry the command
  2. Log the full probe JSON to see the actual shape and compare with expected {ok:true,user_id,username} or {kind:'auth'}
  3. Clear Hupu cookies and re-authenticate — a corrupted cookie set can make the probe script fail
  4. Check for Hupu site changes (redirects, captcha walls) and update the probe script in clis/hupu/auth.js

Example fix

// before
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);
// after
if (!probe) throw new CommandExecutionError('Hupu probe returned no result — page may have failed to load');
if (probe.error) throw new CommandExecutionError(`Hupu probe failed: ${probe.error}`);
if (!probe.ok) throw new CommandExecutionError(`Unexpected Hupu probe: ${JSON.stringify(probe)}`);
Defensive patterns

Strategy: try-catch

Validate before calling

const cookies = await page.context().cookies('https://hupu.com');
if (!cookies.some(c => c.name === 'u')) await runHupuLogin(page);

Type guard

function isProbeOk(p) {
  return !!p && typeof p === 'object' && p.ok === true && typeof p.user_id === 'string';
}

Try / catch

try {
  const identity = await verifyHupuIdentity(page);
} catch (e) {
  if (e instanceof AuthRequiredError) await relogin();
  else if (/Unexpected Hupu probe/.test(e.message)) await retryWithFreshPage(page);
  else throw e;
}

Prevention

When it happens

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

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

Related errors


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