jackwener/OpenCLI · error · ArgumentError
Cannot unfollow yourself
Error message
Cannot unfollow yourself
What it means
After resolving the target mid, the command compares it with the logged-in user's own uid (getSelfUid) and throws ArgumentError 'Cannot unfollow yourself' if they match. Unfollowing yourself is not a valid bilibili relation operation, so it is blocked up front.
Source
Thrown at clis/bilibili/unfollow.js:58
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 unfollow');
}
const mid = await resolveTargetMid(page, kwargs.target);
const self = await getSelfUid(page);
if (mid === self) {
throw new ArgumentError('Cannot unfollow yourself');
}
const attribute = await fetchRelationAttribute(page, mid);
const url = `https://space.bilibili.com/${mid}`;
// attribute 2=following, 6=mutual. Anything else means the viewer isn't
// currently following — skip the POST and return idempotent status.
if (attribute !== 2 && attribute !== 6) {
return [{ mid, name: '', status: 'not-following', url }];
}
const payload = await apiPost(page, '/x/relation/modify', {
params: { fid: mid, act: 2, re_src: 11 },
});
requireOkPayload(payload, 'relation modify');
await waitForRelation(page, mid, (nextAttribute) => nextAttribute !== 2 && nextAttribute !== 6, 'not following');
return [{ mid, name: '', status: 'unfollowed', url }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a different target — the uid/space URL of the UP主 you actually want to unfollow
- Filter your own uid out of any batch list before calling unfollow
- If you intended to inspect your own follows, use the follow-list command instead
Example fix
// before
const target = await getSelfUid(page);
await bilibiliUnfollow({ target });
// after
if (target === selfUid) return; // skip self
await bilibiliUnfollow({ target }); Defensive patterns
Strategy: validation
Validate before calling
const selfUid = await getSelfUid(page);
const targetUid = String(target).match(/space\.bilibili\.com\/(\d+)/i)?.[1] ?? (/^\d+$/.test(target) ? target : null);
if (targetUid != null && targetUid === selfUid) {
throw new Error(`Refusing to unfollow yourself (${selfUid})`);
} Type guard
function isNotSelf(targetUid, selfUid) {
return String(targetUid) !== String(selfUid);
} Try / catch
try {
await bilibiliUnfollow({ target });
} catch (err) {
if (err instanceof ArgumentError && err.message === 'Cannot unfollow yourself') {
console.warn('Skipping self account in batch');
} else throw err;
} Prevention
- Filter your own uid out of batch unfollow lists using getSelfUid
- Never use your own profile URL as a test target
- In batch scripts, log-and-skip when target equals self instead of aborting
When it happens
Trigger: Running `bilibili unfollow --target <your own uid or space URL>` where the resolved mid equals the authenticated user's uid.
Common situations: Testing the command against your own account; a script iterating over a follow list that accidentally includes the self account; pasting your own profile URL as a placeholder target.
Related errors
- bilibili unfollow target cannot be empty
- bilibili unfollow target must be a valid space.bilibili.com/
- Cannot resolve Bilibili target from input: ${trimmed}
- Expected an exact BVID or bilibili.com video URL, for exampl
- Expected a trusted HTTPS bilibili.com video URL without cred
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/08b342ae30f20924.
Report an issue: GitHub.