{"record":{"id":"af5813f4dd138999","repo":"jackwener/OpenCLI","slug":"data-error-are-you-logged-into-creator-xiaohon-af5813","errorCode":null,"errorMessage":"${data.error}. Are you logged into creator.xiaohongshu.com?","messagePattern":"(.+?)\\. Are you logged into creator\\.xiaohongshu\\.com\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/creator-stats.js","lineNumber":49,"sourceCode":"    func: async (page, kwargs) => {\n        const period = kwargs.period || 'seven';\n        // Navigate to creator center for cookie context\n        await page.goto('https://creator.xiaohongshu.com/new/home');\n        const data = await page.evaluate(`\n      async () => {\n        try {\n          const resp = await fetch('/api/galaxy/creator/data/note_detail_new', {\n            credentials: 'include',\n          });\n          if (!resp.ok) return { error: 'HTTP ' + resp.status };\n          return await resp.json();\n        } catch (e) {\n          return { error: e.message };\n        }\n      }\n    `);\n        if (data?.error) {\n            throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');\n        }\n        if (!data?.data) {\n            throw new Error('Unexpected response structure');\n        }\n        const stats = data.data[period];\n        if (!stats) {\n            throw new EmptyResultError('xiaohongshu creator-stats', `No data for period \"${period}\". Available: ${Object.keys(data.data).join(', ')}`);\n        }\n        // Format daily trend as sparkline-like summary\n        const formatTrend = (list) => {\n            if (!list || !list.length)\n                return '-';\n            return list.map((d) => d.count).join(' → ');\n        };\n        return [\n            { metric: '观看数 (views)', total: stats.view_count ?? 0, trend: formatTrend(stats.view_list) },\n            { metric: '平均观看时长 (avg view time ms)', total: stats.view_time_avg ?? 0, trend: formatTrend(stats.view_time_list) },\n            { metric: '主页访问 (home views)', total: stats.home_view_count ?? 0, trend: formatTrend(stats.home_view_list) },","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/creator-stats.js#L31-L67","documentation":"The creator-stats in-page script catches its own exception and returns `{ error: e.message }`; the CLI rethrows it with a hint asking whether you are logged into creator.xiaohongshu.com. The underlying page-side message is preserved as the prefix. This exists because most failures of this script are authentication or permission failures on the creator dashboard.","triggerScenarios":"Any exception inside the page.evaluate script that its try/catch converted to `{ error: e.message }` — e.g. a page-side fetch to the stats endpoint failed with an auth error, a required element was missing, or the request threw.","commonSituations":"Expired xiaohongshu session cookies in the automation profile; running against the wrong host/URL; the creator account lacks stats permissions; Xiaohongshu endpoints changed and the in-page script threw.","solutions":["Open creator.xiaohongshu.com in the browser profile used by the CLI and re-login if the session expired","Read the error prefix (the original page-side message) to identify the real in-page failure","Verify the command targets creator.xiaohongshu.com and the correct account/note","Clear stale cookies or refresh the auth profile and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before calling: confirm session is alive\nconst loggedIn = await page.evaluate(() => location.hostname === 'creator.xiaohongshu.com' && !document.querySelector('.login-btn'));\nif (!loggedIn) throw new Error('Not logged into creator.xiaohongshu.com');","typeGuard":null,"tryCatchPattern":"try {\n  const stats = await getCreatorStats({ period });\n} catch (e) {\n  if (e.message.includes('Are you logged into creator.xiaohongshu.com')) {\n    // refresh login/session cookies, then retry once\n  } else { throw e; }\n}","preventionTips":["Refresh the xiaohongshu session cookies regularly; sessions expire","Read the error prefix — it contains the real in-page failure reason","Confirm the correct hostname (creator.xiaohongshu.com) is targeted"],"tags":["authentication","session-expired","puppeteer","scraping"],"backgroundTag":"creator-login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}