{"record":{"id":"7f1ac1348d7bccea","repo":"jackwener/OpenCLI","slug":"xiaohongshu-unfollow-expected-xiaohongshu-profile","errorCode":null,"errorMessage":"xiaohongshu/unfollow: expected Xiaohongshu profile host, got ${parsedHref.hostname}","messagePattern":"xiaohongshu/unfollow: expected Xiaohongshu profile host, got (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/unfollow.js","lineNumber":215,"sourceCode":"    ],\n    columns: ['status', 'user_id', 'url'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for xiaohongshu unfollow');\n        }\n        try {\n            const userId = assertUserId(kwargs['user-id']);\n            const url = `https://www.xiaohongshu.com/user/profile/${userId}`;\n            await page.goto(url);\n            await page.wait({ time: PROFILE_SETTLE_MS / 1000 });\n\n            const hrefRaw = unwrapEvaluateResult(await page.evaluate('() => location.href'));\n            if (typeof hrefRaw !== 'string') {\n                throw new CommandExecutionError('xiaohongshu/unfollow: malformed current-url payload');\n            }\n            const parsedHref = new URL(hrefRaw);\n            if (parsedHref.protocol !== 'https:' || !isXiaohongshuHost(parsedHref.hostname)) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/unfollow: expected Xiaohongshu profile host, got ${parsedHref.hostname}`,\n                );\n            }\n            if (/\\/login(?:[/?#]|$)/i.test(parsedHref.pathname)) {\n                throw new AuthRequiredError('www.xiaohongshu.com');\n            }\n            const currentProfile = parsedHref.pathname.match(/^\\/user\\/profile\\/([a-zA-Z0-9]{8,32})\\/?$/);\n            if (currentProfile?.[1] !== userId) {\n                throw new CommandExecutionError(\n                    `xiaohongshu/unfollow: expected profile ${userId}, got ${parsedHref.pathname}`,\n                );\n            }\n\n            // Step 1: click 已关注 (idempotent — bails out if 关注 is visible)\n            const clickResult = requireActionResult(\n                await page.evaluate(buildClickUnfollowScript()),\n                'click-unfollow',\n            );","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/unfollow.js#L197-L233","documentation":"After navigation, the command verifies the browser actually landed on an https://*.xiaohongshu.com page. If the final URL's protocol is not https or the hostname is not a xiaohongshu.com domain (e.g. a redirect to a login gateway, carrier captive portal, or anti-bot interstitial), this CommandExecutionError naming the offending hostname is thrown.","triggerScenarios":"The site redirected off-domain (e.g. to a risk-control or verification page on another host); DNS hijacking or corporate proxy rewriting the domain; a hosts-file override pointing www.xiaohongshu.com elsewhere; the browser resolving to a mirror or an error page whose hostname differs.","commonSituations":"Running from a network with a transparent proxy/VPN that intercepts xiaohongshu.com; DNS pollution (common on some networks/regions) redirecting the domain; anti-bot challenge redirecting to a third-party captcha host; mistyped proxy config in the browser profile.","solutions":["Check the reported hostname in the message and resolve www.xiaohongshu.com from the same machine (nslookup/ping) to detect DNS hijack or proxy rewriting","Disable/fix VPN, proxy, or hosts-file entries that rewrite xiaohongshu.com and retry","Open the profile URL manually in the automated Chrome and complete any risk-control/verification challenge, then re-run","Retry from a different network if your current network intercepts the domain"],"exampleFix":"// hosts file before\n203.0.113.9 www.xiaohongshu.com\n// after (remove the override, use real DNS)\n# entry removed","handlingStrategy":"try-catch","validationCode":"// pre-check DNS on your machine\nconst { addresses } = await dns.promises.lookup('www.xiaohongshu.com');\nif (!addresses.length) throw new Error('www.xiaohongshu.com does not resolve — check proxy/hosts');","typeGuard":null,"tryCatchPattern":"try { await cli.unfollow({ 'user-id': id }); } catch (e) { if (/expected Xiaohongshu profile host/.test(String(e.message))) { /* disable VPN/proxy, fix hosts/DNS, or complete the challenge then retry */ } else throw e; }","preventionTips":["Avoid VPNs/proxies that rewrite or intercept xiaohongshu.com","Keep the hosts file free of domain overrides","Run from networks without DNS pollution, or use trusted DNS (DoH)","Complete any anti-bot challenge in the automated browser before running"],"tags":["network","redirect","dns","automation"],"backgroundTag":"unexpected-redirect-host","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}