jackwener/OpenCLI · error · AuthRequiredError

reuters.com

Error message

reuters.com

What it means

verifyReutersIdentity (the reuters whoami/identity verify step) throws AuthRequiredError for reuters.com when its in-page probe finds the localStorage key rcom-subscription-state missing or its isLoggedIn flag not true — i.e. there is no authenticated Reuters session in the browser.

Source

Thrown at clis/reuters/auth.js:41

          try {
            const u = JSON.parse(localStorage.getItem(oidcKey) || '{}');
            cuid = String(u?.profile?.cuid || u?.profile?.sub || '');
          } catch {}
        }
        if (!cuid) {
          const ajs = localStorage.getItem('ajs_user_id');
          if (ajs && ajs !== 'null') cuid = ajs;
        }
        if (!cuid) {
          return { kind: 'auth', detail: 'Reuters logged-in but cuid missing — session shape drifted' };
        }
        return { ok: true, user_id: cuid, subscribed: Boolean(subState.isSubscribed) };
      } catch (e) {
        return { kind: 'exception', detail: String(e && e.message || e) };
      }
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('reuters.com', probe.detail);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Reuters whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Reuters probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, subscribed: probe.subscribed };
}

registerSiteAuthCommands({
  site: 'reuters',
  domain: 'reuters.com',
  loginUrl: 'https://www.reuters.com/account/sign-in/',
  columns: ['user_id', 'subscribed'],
  verify: verifyReutersIdentity,
  // No-navigation poll: check localStorage on the current page so login-flow
  // polling doesn't bounce the user off the sign-in page every interval.
  poll: async (page) => {
    const loggedIn = await page.evaluate(`(() => {
      try {
        const raw = localStorage.getItem('rcom-subscription-state');
        return raw ? JSON.parse(raw).isLoggedIn === true : false;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the reuters auth login command and complete sign-in in the browser
  2. Re-run whoami after login to confirm the session registers
  3. If logged in but still failing with 'cuid missing', re-login to rebuild localStorage keys
  4. Clear site data and log in fresh if the session state is stale

Example fix

// before
reuters whoami   # AuthRequiredError: anonymous
// after
reuters auth login   # complete sign-in flow
reuters whoami       # -> { user_id: "cuid...", subscribed: true }
Defensive patterns

Strategy: try-catch

Validate before calling

// caller-side precheck (mirrors the probe)
const raw = localStorage.getItem('rcom-subscription-state');
const loggedIn = raw ? JSON.parse(raw).isLoggedIn === true : false;
if (!loggedIn) throw new Error('reuters.com session required — run auth login first');

Type guard

function isReutersLoggedIn(raw) {
  try { return JSON.parse(raw)?.isLoggedIn === true; } catch { return false; }
}

Try / catch

try {
  return await reutersWhoami();
} catch (e) {
  if (e instanceof AuthRequiredError || e.constructor.name === 'AuthRequiredError') {
    await runSiteAuthLogin('reuters');
    return await reutersWhoami();
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the reuters identity/whoami command with no prior login; a logged-out or expired session; localStorage cleared; the probe also fires when logged in but the cuid cannot be recovered (session shape drifted), reported via the probe detail.

Common situations: Forgetting to run `reuters auth login` before whoami; Reuters session expiring after inactivity; browser profile reset wiping localStorage; a Reuters frontend change renaming the localStorage keys, so a logged-in user still appears anonymous.

Related errors


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