{"record":{"id":"8e482504512ba2e3","repo":"jackwener/OpenCLI","slug":"xiaoyuzhou-history-stopped-at-the-max-pages-safe","errorCode":null,"errorMessage":"Xiaoyuzhou history stopped at the --max-pages safety limit (${maxPages}) before reaching the end","messagePattern":"Xiaoyuzhou history stopped at the --max-pages safety limit \\((.+?)\\) before reaching the end","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaoyuzhou/history.js","lineNumber":218,"sourceCode":"                        ? Number(((progress.progressSec / episode.durationSec) * 100).toFixed(1))\n                        : null,\n                    playedAt: progress.playedAt,\n                    pubDate: episode.pubDate,\n                    finished: episode.finished,\n                    url: `https://www.xiaoyuzhoufm.com/episode/${episode.eid}`,\n                });\n            }\n        }\n        if (!fetchAll && rows.length >= limit) break;\n        if (page.next === null) {\n            exhausted = true;\n            break;\n        }\n        if (page.next === loadMoreKey || seenCursors.has(page.next)) {\n            throw new CommandExecutionError('Xiaoyuzhou history pagination repeated the same cursor');\n        }\n        if (pageNumber === maxPages) {\n            throw new CommandExecutionError(\n                `Xiaoyuzhou history stopped at the --max-pages safety limit (${maxPages}) before reaching the end`,\n            );\n        }\n        seenCursors.add(page.next);\n        loadMoreKey = page.next;\n    }\n\n    if (rows.length === 0) {\n        throw new EmptyResultError('xiaoyuzhou history', 'The logged-in account has no playback history');\n    }\n    if (fetchAll && !exhausted) {\n        throw new CommandExecutionError('Xiaoyuzhou history archive did not reach the end of pagination');\n    }\n    return rows;\n}\n\ncli({\n    site: 'xiaoyuzhou',","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaoyuzhou/history.js#L200-L236","documentation":"--max-pages is a safety cap on pagination. If the page limit is reached and the feed still has a next cursor, fetchHistory refuses to return a silently truncated result and throws, telling you the archive was not fully read.","triggerScenarios":"Fetching history with --all (or a large --limit) when the account has more pages than maxPages; using the default max-pages with a very large history; a stuck cursor making pagination never end until the cap triggers.","commonSituations":"Long-standing accounts with thousands of entries; DEFAULT_MAX_PAGES too small for the account; users unaware of the safety cap; the cap firing as the terminal symptom of a cursor loop (error 4926).","solutions":["Raise the cap: pass a larger --max-pages (up to HARD_MAX_PAGES) for full-archive runs.","Use --limit to fetch only the most recent N entries instead of the entire archive.","If the cap fires alongside repeated-cursor errors, fix the cursor problem first — the cap may be masking a loop.","Paginate in batches yourself: run with --limit, remember the last entry, and resume in a subsequent call if the API supports it."],"exampleFix":"// before\nawait fetchHistory({ all: true }); // aborts at default max-pages\n// after\nawait fetchHistory({ all: true, 'max-pages': 500 });","handlingStrategy":"validation","validationCode":"if (fetchAll && expectedEntries > maxPages * pageSize) {\n  throw new Error(`--max-pages too small; need ~${Math.ceil(expectedEntries / pageSize)} pages`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await fetchHistory({ all: true, 'max-pages': 500 });\n} catch (e) {\n  if (/max-pages safety limit/.test(e.message)) {\n    console.error('Archive larger than page cap; raise --max-pages or use --limit');\n  } else throw e;\n}","preventionTips":["Set --max-pages proportional to expected archive size.","Prefer --limit when the full archive is not needed.","Investigate cursor loops (which exhaust the cap) before raising limits."],"tags":["pagination","safety-limit","configuration","cli"],"backgroundTag":"pagination-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}