{"record":{"id":"00dd4b0ecc1d211c","repo":"jackwener/OpenCLI","slug":"jike-search-pagination-exceeded-max-pages-pages","errorCode":null,"errorMessage":"Jike search pagination exceeded ${MAX_PAGES} pages before satisfying --limit","messagePattern":"Jike search pagination exceeded (.+?) pages before satisfying --limit","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jike/search.js","lineNumber":69,"sourceCode":"            rows.push(row);\n            if (rows.length >= limit) return rows;\n        }\n        const next = body.loadMoreKey;\n        if (next == null) {\n            if (rows.length === 0) throw new EmptyResultError('jike search', `No posts found for \"${keyword}\"`);\n            return rows;\n        }\n        if (typeof next !== 'object' || Array.isArray(next)) {\n            throw new CommandExecutionError('Jike search API returned a malformed pagination cursor');\n        }\n        const cursorKey = JSON.stringify(next);\n        if (seenCursors.has(cursorKey)) {\n            throw new CommandExecutionError('Jike search pagination returned a repeated cursor');\n        }\n        seenCursors.add(cursorKey);\n        loadMoreKey = next;\n    }\n    throw new CommandExecutionError(`Jike search pagination exceeded ${MAX_PAGES} pages before satisfying --limit`);\n}\n\ncli({\n    site: 'jike',\n    name: 'search',\n    access: 'read',\n    description: '搜索即刻帖子',\n    domain: 'web.okjike.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'query', type: 'string', required: true, positional: true, help: '即刻搜索关键词' },\n        { name: 'limit', type: 'int', default: DEFAULT_LIMIT },\n    ],\n    columns: ['id', 'author', 'content', 'likes', 'comments', 'time', 'url'],\n    func: async (page, kwargs) => {\n        const keyword = String(kwargs.query || '').trim();\n        if (!keyword) throw new ArgumentError('Jike search query cannot be empty');","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jike/search.js#L51-L87","documentation":"searchPosts caps pagination at MAX_PAGES (50) iterations to bound API calls. If --limit demands more rows than 50 pages of ~20 results can supply — or cursors keep coming without enough ORIGINAL_POST rows — it throws CommandExecutionError. This prevents unbounded crawling of the Jike search endpoint.","triggerScenarios":"rows.length never reaches --limit within 50 page requests, e.g. --limit set extremely high (1000+) or the search returns mostly non-ORIGINAL_POST items (comments, topics) that get filtered out.","commonSituations":"User passes an oversized --limit expecting more results than Jike will serve; keyword results dominated by non-original-post result types; Page size (PAGE_SIZE=20) reduced server-side so 50 pages no longer suffice.","solutions":["Lower --limit to a value the search can actually supply (e.g. 100 or fewer).","Catch the error and use whatever partial data you collected, or drop the limit.","Raise MAX_PAGES locally if you genuinely need deeper paging and accept the API load.","Narrow the keyword so result pages contain a higher share of ORIGINAL_POST items."],"exampleFix":"// before\nconst rows = await runCli(['jike', 'search', keyword, '--limit', '2000']);\n// after\nconst rows = await runCli(['jike', 'search', keyword, '--limit', '100']); // within MAX_PAGES * PAGE_SIZE","handlingStrategy":"validation","validationCode":"// enforce a feasible limit before calling\nconst MAX_FEASIBLE = 50 * 20; // MAX_PAGES * PAGE_SIZE\nif (requested > MAX_FEASIBLE) requested = MAX_FEASIBLE;","typeGuard":null,"tryCatchPattern":"try {\n  return await runCli(['jike', 'search', keyword, '--limit', n]);\n} catch (e) {\n  if (/pagination exceeded/.test(e.message)) return runCli(['jike', 'search', keyword, '--limit', 100]);\n  throw e;\n}","preventionTips":["Keep --limit well under MAX_PAGES * PAGE_SIZE (1000).","Prefer narrower keywords so pages contain more ORIGINAL_POST rows.","Treat the error as 'asked for too many results', not an outage."],"tags":["pagination","limits","jike"],"backgroundTag":"pagination-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}