jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

After the whoami probe runs, verifyReutersIdentity expects probe to be an object with ok true plus user_id/subscribed. If probe is undefined/null or has ok falsy (but is neither 'auth' nor 'exception'), the library throws this CommandExecutionError because the probe returned an unrecognized/unexpected shape.

Source

Thrown at clis/reuters/auth.js:43

            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;
      } catch { return false; }
    })()`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the JSON.stringify(probe) payload in the message to see what the probe actually returned.
  2. Reload the page and retry, ensuring navigation completes before the probe runs.
  3. Log in to reuters.com first so the probe finds a valid session and returns ok:true.
  4. Update the whoami script if Reuters changed the identity endpoint/localStorage keys it reads.

Example fix

// before
const who = await verifyReutersIdentity(page);
// after
await page.goto('https://www.reuters.com');
await page.wait(3);
const who = await verifyReutersIdentity(page);
if (!who) throw new Error('Reuters identity unavailable; try logging in again');
Defensive patterns

Strategy: type-guard

Validate before calling

// pre-check that a session exists before verifying identity
const state = await page.evaluate("localStorage.getItem('rcom-subscription-state')");
if (!state) throw new Error('Not logged in to reuters.com; login first');

Type guard

function isOkProbe(p) {
  return p != null && typeof p === 'object' &&
    p.ok === true && typeof p.user_id !== 'undefined' && typeof p.subscribed === 'boolean';
}

Try / catch

try {
  const who = await verifyReutersIdentity(page);
} catch (e) {
  if (/Unexpected Reuters probe/.test(e.message)) {
    // probe returned null/unexpected shape: reload and retry
    await page.goto('https://www.reuters.com');
    await page.wait(5);
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: page.evaluate returned null/undefined (script was interrupted or returned nothing) or returned an object without ok:true — probe?.ok is falsy at clis/reuters/auth.js:43, so the object is stringified into the message.

Common situations: Navigation cancelled mid-evaluate (page redirected); site served a bot-check or consent page so the probe script silently returned undefined; the whoami script's return value changed shape after a Reuters update.

Related errors


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