{"record":{"id":"4c272d73da164999","repo":"jackwener/OpenCLI","slug":"cannot-follow-yourself","errorCode":null,"errorMessage":"Cannot follow yourself","messagePattern":"Cannot follow yourself","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/follow.js","lineNumber":66,"sourceCode":"    domain: 'www.bilibili.com',\n    strategy: Strategy.COOKIE,\n    args: [\n        {\n            name: 'target',\n            required: true,\n            positional: true,\n            help: '目标 UID / 用户名 / space.bilibili.com 链接',\n        },\n    ],\n    columns: ['mid', 'name', 'status', 'url'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for bilibili follow');\n        }\n        const mid = await resolveTargetMid(page, kwargs.target);\n        const self = await getSelfUid(page);\n        if (mid === self) {\n            throw new ArgumentError('Cannot follow yourself');\n        }\n        const attribute = await fetchRelationAttribute(page, mid);\n        const url = `https://space.bilibili.com/${mid}`;\n        if (attribute === 2 || attribute === 6) {\n            return [{ mid, name: '', status: 'already-following', url }];\n        }\n        if (attribute === 128) {\n            throw new CommandExecutionError(\n                `Bilibili user ${mid} is blocked; unblock first before following.`,\n            );\n        }\n        // act=1 follow, act=2 unfollow. re_src=11 is the community-standard\n        // \"web\" source value used by third-party libs (bilibili-api-python etc.);\n        // omitting it makes the modify API reject with a vague code.\n        const payload = await apiPost(page, '/x/relation/modify', {\n            params: { fid: mid, act: 1, re_src: 11 },\n        });\n        requireOkPayload(payload, 'relation modify');","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/follow.js#L48-L84","documentation":"After resolving the target mid, the command fetches your own UID via getSelfUid and refuses to follow yourself (mid === self), throwing this ArgumentError — the follow API would reject it anyway and the state is meaningless.","triggerScenarios":"Passing your own UID/username/space URL as the follow target, or getSelfUid resolving to the same account you typed.","commonSituations":"Testing the CLI against your own account, looping over a list of UIDs that includes yours, reusing a config where the target was set to your own profile.","solutions":["Choose a different target account.","Filter your own mid out of any batch target list before running.","Verify which account the browser is logged in as if you did not expect a self-follow."],"exampleFix":"// before\nfor (const uid of uids) await follow(uid);\n// after\nconst self = await getSelfUid(page);\nfor (const uid of uids.filter((u) => u !== self)) await follow(uid);","handlingStrategy":"validation","validationCode":"const self = await getSelfUid(page);\nconst mid = await resolveTargetMid(page, target);\nif (mid === self) throw new Error(`refusing self-follow: ${mid}`);","typeGuard":"function isNotSelf(mid, selfUid) {\n  return String(mid) !== String(selfUid);\n}","tryCatchPattern":"try {\n  await follow(target);\n} catch (e) {\n  if (e instanceof ArgumentError && e.message === 'Cannot follow yourself') {\n    console.warn('target equals the logged-in account; skipping');\n    return;\n  }\n  throw e;\n}","preventionTips":["Know which account your session is logged in as","Filter the logged-in uid out of batch target lists","Compare resolved mids (not raw input) before following"],"tags":["validation","argument-error","bilibili"],"backgroundTag":"invalid-operation-self-referential","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}