jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

Final guard in verifyPixivIdentity: after excluding kinds auth/http/exception, the probe must have ok=true. If it doesn't (probe null, an unrecognized kind, or an object lacking ok), this CommandExecutionError is thrown with the whole probe JSON-serialized. It indicates the probe returned an unexpected shape — usually a bug or an unhandled pixiv response variant.

Source

Thrown at clis/pixiv/auth.js:47

        return { kind: 'auth', detail: 'Pixiv /ajax/user/extra HTTP ' + r.status };
      }
      if (!r.ok) return { kind: 'http', httpStatus: r.status };
      const d = await r.json();
      if (d?.error) return { kind: 'auth', detail: 'Pixiv /ajax/user/extra error=true — anonymous' };
      const phpSess = (document.cookie.split('; ').find(c => c.startsWith('PHPSESSID=')) || '').split('=')[1] || '';
      const uid = phpSess.split('_')[0] || '';
      if (!uid) {
        return { kind: 'auth', detail: 'Pixiv PHPSESSID prefix unparseable' };
      }
      return { ok: true, user_id: uid, name: '' };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('pixiv.net', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Pixiv ajax`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Pixiv whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Pixiv probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'pixiv',
  domain: 'pixiv.net',
  loginUrl: 'https://accounts.pixiv.net/login',
  columns: ['user_id', 'name'],
  quickCheck: hasPixivSessionCookie,
  verify: verifyPixivIdentity,
  poll: async (page) => {
    if (!await hasPixivSessionCookie(page)) {
      throw new AuthRequiredError('pixiv.net', 'Waiting for Pixiv PHPSESSID cookie');
    }
    return verifyPixivIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the JSON payload in the message to see what the probe actually returned.
  2. Retry — if the page navigated mid-probe, a fresh run on a stable pixiv.net page should work.
  3. Ensure the browser stays on pixiv.net (no redirects/navigation) while verification runs.
  4. Update the CLI/probe if the message reveals a new probe result shape that isn't handled.
Defensive patterns

Strategy: try-catch

Type guard

function isKnownProbeResult(probe) {
  return !!probe && (probe.ok === true
    || probe.kind === 'auth' || probe.kind === 'http'
    || probe.kind === 'exception');
}

Try / catch

try {
  await pixivWhoAmI();
} catch (err) {
  if (String(err.message).startsWith('Unexpected Pixiv probe:')) {
    const probe = JSON.parse(String(err.message).slice('Unexpected Pixiv probe:'.length));
    // inspect probe shape, report bug or handle new kind
  } else throw err;
}

Prevention

When it happens

Trigger: page.evaluate returns null/undefined (page navigated mid-probe or evaluation failed silently), or the probe returns an object that is neither a known kind nor {ok:true,...} — i.e. none of the earlier branches matched.

Common situations: Page navigated or closed during the evaluate so the result was lost; pixiv served a completely different page variant; a CLI/probe version mismatch after a refactor added a new probe result kind the thrower doesn't know.

Related errors


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