jackwener/OpenCLI · error · CommandExecutionError
Stack Exchange answer comments for ${label} exceed one API p
Error message
Stack Exchange answer comments for ${label} exceed one API page What it means
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.
Source
Thrown at clis/stackoverflow/read.js:144
const ansCommentsData = await fetchJson(
`${SE_API_BASE}/answers/${ids}/comments?site=${SE_SITE}&filter=withbody&order=asc&sort=creation&pagesize=${pageSize}`,
`${label}/answer-comments`,
);
for (const c of ansCommentsData.items || []) {
if (!c.post_id) continue;
if (!answerCommentsByAnswerId.has(c.post_id)) {
answerCommentsByAnswerId.set(c.post_id, []);
}
answerCommentsByAnswerId.get(c.post_id).push(c);
}
if (ansCommentsData.has_more) {
const missingForSelectedAnswer = answers.some((answer) => {
const comments = answerCommentsByAnswerId.get(answer.answer_id) || [];
return comments.length < commentsLimit;
});
if (missingForSelectedAnswer) {
throw new CommandExecutionError(
`Stack Exchange answer comments for ${label} exceed one API page`,
'Lower --answers-limit or --comments-limit; refusing to return a partial answer-comment set.',
);
}
}
return answerCommentsByAnswerId;
}
const NAMED_ENTITIES = {
amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ',
hellip: '…', mdash: '—', ndash: '–', laquo: '«', raquo: '»',
copy: '©', reg: '®', trade: '™', euro: '€', pound: '£', yen: '¥',
rsquo: '’', lsquo: '‘', rdquo: '”', ldquo: '“',
};
/** Decode named/numeric HTML entities. Used on both body HTML and display names. */
function decodeEntities(text) {View on GitHub (pinned to 49907e53dc)
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
Example fix
// before stackoverflow read 79935770 --answers-limit 30 --comments-limit 100 // after stackoverflow read 79935770 --answers-limit 5 --comments-limit 20
Defensive patterns
Strategy: fallback
Validate before calling
null
Type guard
null
Try / catch
try {
const rows = await runCommand(['stackoverflow', 'read', id, '--answers-limit', a, '--comments-limit', c]);
} catch (e) {
if (e instanceof CommandExecutionError && e.message.includes('exceed one API page')) {
// fallback: retry with smaller limits or query the API directly with page/page=2 pagination
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- xiaohongshu creator-notes: captured ${items.length} of ${Mat
- limit must be a positive integer (1-${max})
- limit must be <= ${max}
- NO_DATA
- ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0ae2bd1b63e49c8d.
Report an issue: GitHub.