{"record":{"id":"0ae2bd1b63e49c8d","repo":"jackwener/OpenCLI","slug":"stack-exchange-answer-comments-for-label-exceed","errorCode":null,"errorMessage":"Stack Exchange answer comments for ${label} exceed one API page","messagePattern":"Stack Exchange answer comments for (.+?) exceed one API page","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/stackoverflow/read.js","lineNumber":144,"sourceCode":"    const ansCommentsData = await fetchJson(\n        `${SE_API_BASE}/answers/${ids}/comments?site=${SE_SITE}&filter=withbody&order=asc&sort=creation&pagesize=${pageSize}`,\n        `${label}/answer-comments`,\n    );\n    for (const c of ansCommentsData.items || []) {\n        if (!c.post_id) continue;\n        if (!answerCommentsByAnswerId.has(c.post_id)) {\n            answerCommentsByAnswerId.set(c.post_id, []);\n        }\n        answerCommentsByAnswerId.get(c.post_id).push(c);\n    }\n\n    if (ansCommentsData.has_more) {\n        const missingForSelectedAnswer = answers.some((answer) => {\n            const comments = answerCommentsByAnswerId.get(answer.answer_id) || [];\n            return comments.length < commentsLimit;\n        });\n        if (missingForSelectedAnswer) {\n            throw new CommandExecutionError(\n                `Stack Exchange answer comments for ${label} exceed one API page`,\n                'Lower --answers-limit or --comments-limit; refusing to return a partial answer-comment set.',\n            );\n        }\n    }\n\n    return answerCommentsByAnswerId;\n}\n\nconst NAMED_ENTITIES = {\n    amp: '&', lt: '<', gt: '>', quot: '\"', apos: \"'\", nbsp: ' ',\n    hellip: '…', mdash: '—', ndash: '–', laquo: '«', raquo: '»',\n    copy: '©', reg: '®', trade: '™', euro: '€', pound: '£', yen: '¥',\n    rsquo: '’', lsquo: '‘', rdquo: '”', ldquo: '“',\n};\n\n/** Decode named/numeric HTML entities. Used on both body HTML and display names. */\nfunction decodeEntities(text) {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/stackoverflow/read.js#L126-L162","documentation":"fetchAnswerCommentsByAnswerId throws this CommandExecutionError when the batched answer-comments endpoint reports has_more=true but at least one selected answer still has fewer comments than commentsLimit — meaning the comments do not fit on a single API page and the result would be partial. The tool refuses to return an incomplete answer-comment set rather than silently truncating.","triggerScenarios":"A question whose answers collectively have many comments plus --answers-limit/--comments-limit settings large enough that GET /answers/{ids}/comments with pagesize=SE_MAX_PAGE_SIZE cannot return them all (has_more=true with a selected answer below its commentsLimit).","commonSituations":"Very popular questions with hundreds of comments across answers; user raising --comments-limit to 50+ while also selecting many answers; older questions where each answer attracted long discussion threads.","solutions":["Lower --answers-limit so fewer answers are selected","Lower --comments-limit so each answer needs fewer comment rows","Fetch the specific question with fewer requested rows, or use the Stack Exchange API directly with page pagination","Split the request by fetching /answers/{id}/comments per answer with page=2 when has_more is true"],"exampleFix":"// before\nstackoverflow read 79935770 --answers-limit 30 --comments-limit 100\n// after\nstackoverflow read 79935770 --answers-limit 5 --comments-limit 20","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const rows = await runCommand(['stackoverflow', 'read', id, '--answers-limit', a, '--comments-limit', c]);\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('exceed one API page')) {\n    // fallback: retry with smaller limits or query the API directly with page/page=2 pagination\n  } else throw e;\n}","preventionTips":["Keep --answers-limit x --comments-limit well below the 100-item page size for busy questions","For high-comment questions, fetch comments per answer with explicit pagination instead of one batched call","Start with small limits and raise them only if has_more stays false","Handle the error by retrying with reduced limits rather than assuming data is missing"],"tags":["pagination","api-limit","partial-data"],"backgroundTag":"api-pagination-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}