jackwener/OpenCLI · error · CommandExecutionError
Browser session required for bilibili follow
Error message
Browser session required for bilibili follow
What it means
The follow command's func requires an authenticated browser page (cookies) to read your own UID and mutate relations. If the framework passes a falsy page (no browser session started / not logged in), the command short-circuits with this CommandExecutionError before doing any work.
Source
Thrown at clis/bilibili/follow.js:61
cli({
site: 'bilibili',
name: 'follow',
access: 'write',
description: '关注 B站用户(官方 API,需登录)',
domain: 'www.bilibili.com',
strategy: Strategy.COOKIE,
args: [
{
name: 'target',
required: true,
positional: true,
help: '目标 UID / 用户名 / space.bilibili.com 链接',
},
],
columns: ['mid', 'name', 'status', 'url'],
func: async (page, kwargs) => {
if (!page) {
throw new CommandExecutionError('Browser session required for bilibili follow');
}
const mid = await resolveTargetMid(page, kwargs.target);
const self = await getSelfUid(page);
if (mid === self) {
throw new ArgumentError('Cannot follow yourself');
}
const attribute = await fetchRelationAttribute(page, mid);
const url = `https://space.bilibili.com/${mid}`;
if (attribute === 2 || attribute === 6) {
return [{ mid, name: '', status: 'already-following', url }];
}
if (attribute === 128) {
throw new CommandExecutionError(
`Bilibili user ${mid} is blocked; unblock first before following.`,
);
}
// act=1 follow, act=2 unfollow. re_src=11 is the community-standard
// "web" source value used by third-party libs (bilibili-api-python etc.);View on GitHub (pinned to 49907e53dc)
Solutions
- Start/log into the browser session before running the follow command (e.g. run the login/open command for this CLI suite).
- Ensure cookies for bilibili.com are present in the browser profile.
- In scripts, check session state before invoking follow.
Example fix
// before
await run('bilibili follow --target 9469745');
// after
await run('login'); // establish browser session first
await run('bilibili follow --target 9469745'); Defensive patterns
Strategy: validation
Validate before calling
if (!session || !session.page) throw new Error('run login / open browser session first'); Type guard
function hasPage(ctx) {
return ctx != null && typeof ctx === 'object' && ctx.page != null;
} Try / catch
try {
await followCommand(page, kwargs);
} catch (e) {
if (String(e.message).includes('Browser session required')) {
await login();
return followCommand(await getSessionPage(), kwargs);
}
throw e;
} Prevention
- Always login before relation-mutating commands
- Keep the browser process alive across CLI invocations
- In CI, provision a logged-in browser profile or skip these commands
- Check session state programmatically before batch runs
When it happens
Trigger: Running bilibili follow without an active browser session, or with a session that failed to start (browser crashed, no profile, headless setup missing).
Common situations: Running in CI without a logged-in browser profile, forgetting the login step of the CLI, or the browser being closed between commands.
Related errors
- Browser session required for bilibili following
- Authentication required — please sign in to Manus in the bro
- Xianyu search requires a logged-in browser session
- ${config.site} login
- Band band_session cookie missing
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1d7d3ec1ca61647e.
Report an issue: GitHub.