{"record":{"id":"0e74644965fc877d","repo":"jackwener/OpenCLI","slug":"xiaohongshu-follow-expected-xiaohongshu-profile-h","errorCode":null,"errorMessage":"xiaohongshu/follow: expected Xiaohongshu profile host, got ${parsedHref.hostname}","messagePattern":"xiaohongshu/follow: expected Xiaohongshu profile host, got (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/follow.js","lineNumber":184,"sourceCode":"    ],\n    columns: ['status', 'user_id', 'url'],\n    func: async (page, kwargs) => {\n        if (!page) {\n            throw new CommandExecutionError('Browser session required for xiaohongshu follow');\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/follow: 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/follow: 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/follow: expected profile ${userId}, got ${parsedHref.pathname}`,\n                );\n            }\n\n            const result = requireActionResult(\n                await page.evaluate(buildFollowScript()),\n                'follow-action',\n            );\n            if (!result.ok) {","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/follow.js#L166-L202","documentation":"After navigation the command asserts the browser actually landed on a https://*.xiaohongshu.com profile page; if the final URL's scheme or host differs, CommandExecutionError names the offending hostname. This catches redirects off-domain (security check: never act on a page that isn't Xiaohongshu).","triggerScenarios":"Xiaohongshu redirected the tab to a different domain (anti-bot gateway, regional mirror, telecom hijack page, or an error page on another host), or an http:// final URL after a redirect chain.","commonSituations":"Aggressive bot detection bouncing to a verification page on another host; DNS hijacking on untrusted networks; expired session landing on an SSO/redirector; corporate proxy rewriting URLs.","solutions":["Open the profile URL manually in the connected browser and complete any verification/captcha, then re-run.","Check the network for DNS/proxy hijacking; try a trusted network or VPN.","Clear site cookies for xiaohongshu.com and log in fresh, then retry the follow command.","If a legitimate new host pattern is being rejected, update isXiaohongshuHost in clis/xiaohongshu/follow.js."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await follow(page, userId);\n} catch (err) {\n  if (err.code === 'COMMAND_EXEC' && err.message.includes('expected Xiaohongshu profile host')) {\n    // a redirect took the tab off-domain: complete any human verification, then retry\n  }\n  throw err;\n}","preventionTips":["Complete anti-bot verification manually in the browser before automation","Use a trusted network to avoid DNS/proxy hijacking redirects","Keep the browser profile's xiaohongshu session fresh to reduce bounce risk"],"tags":["redirect","host-validation","anti-bot","browser-automation","xiaohongshu"],"backgroundTag":"unexpected-redirect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}