jackwener/OpenCLI · warning · CommandExecutionError

Unexpected WeRead probe: ${JSON.stringify(result)}

Error message

Unexpected WeRead probe: ${JSON.stringify(result)}

What it means

verifyWereadIdentity in clis/weread/auth.js throws CommandExecutionError as a last-resort guard when the probe result has no recognized shape: kind is not 'auth'/'http'/'exception' and result.ok is falsy. It means the in-page script returned null/undefined or an unexpected object, so the library cannot classify the outcome.

Source

Thrown at clis/weread/auth.js:42

      }
      if (!res.ok) return { kind: 'http', httpStatus: res.status };
      const d = await res.json();
      if (d && d.errCode && d.errCode !== 0) {
        return { kind: 'auth', detail: 'WeRead /web/user errCode=' + d.errCode };
      }
      return {
        ok: true,
        user_id: String(d.userVid || wrVid),
        name: String(d.name || d.nickName || ''),
      };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('weread.qq.com', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /web/user`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`WeRead whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected WeRead probe: ${JSON.stringify(result)}`);
  return { user_id: result.user_id, name: result.name };
}

registerSiteAuthCommands({
  site: 'weread',
  domain: 'weread.qq.com',
  loginUrl: 'https://weread.qq.com/',
  columns: ['user_id', 'name'],
  quickCheck: hasWereadSessionCookie,
  verify: verifyWereadIdentity,
  poll: async (page) => {
    if (!await hasWereadSessionCookie(page)) {
      throw new AuthRequiredError('weread.qq.com', 'Waiting for WeRead wr_vid cookie');
    }
    return verifyWereadIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command — a transient navigation race often makes evaluate return undefined once.
  2. Check the JSON.stringify(result) in the message to see what actually came back and adjust.
  3. Re-login with `weread login` so page.goto lands on the real weread.qq.com page, not a redirect wall.
  4. Update the CLI/automation driver if evaluate consistently returns null (environment/version mismatch).

Example fix

// before
CommandExecutionError: Unexpected WeRead probe: null
// after: retry after ensuring the weread.qq.com tab is on a stable page
$ opencli weread login && opencli weread whoami
Defensive patterns

Strategy: try-catch

Type guard

function isProbeResult(r) { return r !== null && typeof r === 'object' && (('kind' in r) || ('ok' in r)); }

Try / catch

try { return await verifyWereadIdentity(page); } catch (e) {
  if (/Unexpected WeRead probe/.test(e.message)) {
    console.error('Probe returned an unrecognized shape (page navigated?) — retry or re-login.');
  } else throw e;
}

Prevention

When it happens

Trigger: page.evaluate returns null or undefined (page navigated, evaluate deserialization issue), or returns an object without kind/ok (e.g. a WeRead script overwrote something, or the evaluate string was mangled), falling through all four kind checks to `!result?.ok`.

Common situations: The tab navigated away between page.goto and evaluate; an automation/driver version mismatch making evaluate return undefined; a redirect page (login wall) replacing the weread.qq.com context; older CLI evaluated against an incompatible page.

Related errors


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