{"record":{"id":"0702d80864544506","repo":"jackwener/OpenCLI","slug":"note-content-requires-login","errorCode":null,"errorMessage":"Note content requires login","messagePattern":"Note content requires login","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/note.js","lineNumber":92,"sourceCode":"    ],\n    columns: ['field', 'value'],\n    func: async (page, kwargs) => {\n        const raw = String(kwargs['note-id']);\n        const noteId = parseNoteId(raw);\n        const url = buildNoteUrl(raw, { commandName: 'xiaohongshu note' });\n        await page.goto(url);\n        await page.wait({ time: 2 + Math.random() * 3 });\n        const data = await page.evaluate(NOTE_EXTRACT_JS);\n        if (!data || typeof data !== 'object') {\n            throw new EmptyResultError('xiaohongshu/note', 'Unexpected evaluate response');\n        }\n        if (data.securityBlock) {\n            throw new CliError('SECURITY_BLOCK', 'Xiaohongshu security block: the note detail page was blocked by risk control.', /^https?:\\/\\//.test(raw)\n                ? 'The page may be temporarily restricted. Try again later or from a different session.'\n                : 'Try using a full URL from search results (with xsec_token) instead of a bare note ID.');\n        }\n        if (data.loginWall) {\n            throw new AuthRequiredError('www.xiaohongshu.com', 'Note content requires login');\n        }\n        if (data.notFound) {\n            throw new EmptyResultError('xiaohongshu/note', `Note ${noteId} not found or unavailable — it may have been deleted or restricted`);\n        }\n        const d = data;\n        // XHS renders placeholder text like \"赞\"/\"收藏\"/\"评论\" when count is 0;\n        // normalize to '0' unless the value looks numeric.\n        const numOrZero = (v) => /^\\d+/.test(v) ? v : '0';\n        // A note may legitimately have no title, but a real note page always\n        // renders an author. If both are missing, the page failed to load.\n        if (!d.title && !d.author) {\n            throw new EmptyResultError('xiaohongshu/note', 'The note page loaded without visible content. The note may be deleted or restricted.');\n        }\n        const rows = [\n            { field: 'title', value: d.title || '' },\n            { field: 'author', value: d.author || '' },\n            { field: 'content', value: d.desc || '' },\n            { field: 'likes', value: numOrZero(d.likes || '') },","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/note.js#L74-L110","documentation":"The extraction script detected data.loginWall, meaning the note detail page requires an authenticated session to view content. AuthRequiredError('www.xiaohongshu.com', 'Note content requires login') is thrown to tell the user to log in to Xiaohongshu in the connected Chrome browser.","triggerScenarios":"page.evaluate(NOTE_EXTRACT_JS) returns { loginWall: true } — the page rendered a login prompt/gate instead of note content because the Chrome session is not logged in or the cookie session expired.","commonSituations":"Session cookies expired; using a fresh Chrome profile that never logged into XHS; XHS now gating note content behind login for that region/account; cookies cleared by browser updates.","solutions":["Log in to www.xiaohongshu.com in the Chrome instance the CLI drives, then rerun.","Refresh the session if cookies expired (visit the site and confirm you stay logged in).","Access the note from a context that doesn't require login (e.g. via a signed URL from search) if available.","Check you are pointing the CLI at the correct Chrome profile."],"exampleFix":"// before\n// CLI attached to a fresh Chrome profile, not logged in\nawait note(url); // throws AuthRequiredError\n// after\n// open Chrome, log into www.xiaohongshu.com, then\nawait note(url);","handlingStrategy":"try-catch","validationCode":"// Best-effort pre-check: confirm an auth cookie exists in the driven Chrome profile\n// (real check requires browser access; the CLI throws AuthRequiredError otherwise)","typeGuard":"function isAuthRequiredError(err) {\n  return err instanceof AuthRequiredError || err?.name === 'AuthRequiredError';\n}","tryCatchPattern":"try {\n  await note(url);\n} catch (err) {\n  if (isAuthRequiredError(err)) {\n    console.error('Log in to www.xiaohongshu.com in the driven Chrome session, then retry.');\n  } else throw err;\n}","preventionTips":["Log in to www.xiaohongshu.com in the Chrome profile the CLI attaches to.","Re-login periodically — cookies expire.","Confirm the CLI points at the correct Chrome user-data-dir/profile.","Handle AuthRequiredError explicitly rather than as a generic failure."],"tags":["xiaohongshu","authentication","login-required"],"backgroundTag":"auth-required-login-wall","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}