{"record":{"id":"5bd04027dbe0eb61","repo":"jackwener/OpenCLI","slug":"no-data-for-period-period-available-objec","errorCode":null,"errorMessage":"No data for period \"${period}\". Available: ${Object.keys(data.data).join(', ')}","messagePattern":"No data for period \"(.+?)\"\\. Available: (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/xiaohongshu/creator-stats.js","lineNumber":56,"sourceCode":"          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) },\n            { metric: '点赞数 (likes)', total: stats.like_count ?? 0, trend: formatTrend(stats.like_list) },\n            { metric: '收藏数 (collects)', total: stats.collect_count ?? 0, trend: formatTrend(stats.collect_list) },\n            { metric: '评论数 (comments)', total: stats.comment_count ?? 0, trend: formatTrend(stats.comment_list) },\n            { metric: '弹幕数 (danmaku)', total: stats.danmaku_count ?? 0, trend: '-' },\n            { metric: '分享数 (shares)', total: stats.share_count ?? 0, trend: formatTrend(stats.share_list) },\n            { metric: '涨粉数 (new followers)', total: stats.rise_fans_count ?? 0, trend: formatTrend(stats.rise_fans_list) },\n        ];","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/creator-stats.js#L38-L74","documentation":"An EmptyResultError thrown when the requested stats `period` key is absent from `data.data`. The response structure was valid, but there is no stats object for the period you asked for; the message lists which period keys the API actually returned. This turns a silent `undefined` into an actionable message.","triggerScenarios":"Calling the creator-stats command with a period string that does not match any key in the returned data object (e.g. requesting a period the API does not provide for this account or date range).","commonSituations":"Typo in the period name; requesting a newer/older period than the account's data covers; Xiaohongshu renamed or removed period keys in its API.","solutions":["Use one of the period keys listed in the 'Available: ...' part of the message","Check the accepted period values for this command and fix the typo","If the key list looks wrong, log `Object.keys(data.data)` to inspect what the API returned","Request a period range the account actually has data for"],"exampleFix":"// before\nawait getCreatorStats({ period: 'last7days' });\n// after\nawait getCreatorStats({ period: '7d' }); // key must match one of the API's returned period keys","handlingStrategy":"validation","validationCode":"const VALID_PERIODS = ['7d', '28d', '90d']; // use the keys the CLI/API documents\nif (!VALID_PERIODS.includes(period)) {\n  throw new Error(`Invalid period \"${period}\". Use one of: ${VALID_PERIODS.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const stats = await getCreatorStats({ period });\n} catch (e) {\n  if (e instanceof EmptyResultError || /No data for period/.test(e.message)) {\n    const available = e.message.match(/Available: (.*)$/)?.[1] ?? '';\n    // pick a valid key from `available` and retry\n  } else { throw e; }\n}","preventionTips":["Parse the 'Available: ...' list from the error message to discover valid period keys","Keep a constant list of accepted periods instead of free-form strings","Check the account's data coverage before requesting older/newer periods"],"tags":["empty-result","invalid-argument","scraping","api-contract"],"backgroundTag":"invalid-period-key","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}