jackwener/OpenCLI · error · CommandExecutionError
Jike notifications API returned a malformed pagination curso
Error message
Jike notifications API returned a malformed pagination cursor
What it means
listNotifications expects body.loadMoreKey, when present, to be a non-null object (the pagination cursor). If it is a primitive or an array, the library cannot serialize/use it as a cursor and throws CommandExecutionError to avoid malformed pagination requests.
Source
Thrown at clis/jike/notifications.js:114
const seenIds = new Set();
const seenCursors = new Set();
let loadMoreKey = null;
for (let pageIndex = 0; pageIndex < MAX_PAGES; pageIndex++) {
const body = await fetchNotificationsPage(page, loadMoreKey);
for (const notification of body.data) {
const row = mapNotification(notification);
if (seenIds.has(notification.id)) continue;
seenIds.add(notification.id);
rows.push(row);
if (rows.length >= limit) return rows;
}
const next = body.loadMoreKey;
if (next == null) {
if (rows.length === 0) throw new EmptyResultError('jike notifications', 'No notifications found');
return rows;
}
if (typeof next !== 'object' || Array.isArray(next)) {
throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');
}
const cursorKey = JSON.stringify(next);
if (seenCursors.has(cursorKey)) {
throw new CommandExecutionError('Jike notifications pagination returned a repeated cursor');
}
seenCursors.add(cursorKey);
loadMoreKey = next;
}
throw new CommandExecutionError(`Jike notifications pagination exceeded ${MAX_PAGES} pages before satisfying --limit`);
}
cli({
site: 'jike',
name: 'notifications',
access: 'read',
description: '即刻通知',
domain: 'web.okjike.com',
strategy: Strategy.COOKIE,View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the raw response's loadMoreKey value to confirm its actual shape
- Update the CLI/library to a version compatible with the new cursor format
- Serialize the cursor safely: wrap string cursors in an object ({ loadMoreKey: next }) before passing along
- Avoid the issue by passing a smaller --limit so pagination ends before the malformed cursor page
Example fix
// before
if (typeof next !== 'object' || Array.isArray(next)) {
throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');
}
// after
const normalizedNext = typeof next === 'string' || typeof next === 'number'
? { loadMoreKey: next }
: next;
if (!normalizedNext || typeof normalizedNext !== 'object' || Array.isArray(normalizedNext)) {
throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');
} Defensive patterns
Strategy: validation
Validate before calling
// validate the response envelope before paginating
function cursorIsUsable(body) {
const c = body?.loadMoreKey;
return c == null || (typeof c === 'object' && !Array.isArray(c));
} Type guard
function isCursor(c) {
return c !== null && typeof c === 'object' && !Array.isArray(c);
} Try / catch
try {
await cli('jike', 'notifications').run();
} catch (e) {
if (String(e.message).includes('malformed pagination cursor')) {
// pin an older API behavior or report/update the CLI
} else throw e;
} Prevention
- Keep the CLI updated for Jike cursor-format changes
- Sanity-check loadMoreKey shape when integrating behind proxies/mocks
- Keep --limit modest so fewer cursor round-trips are needed
When it happens
Trigger: The Jike notifications endpoint returns loadMoreKey as a string, number, or array instead of an object — e.g. an API envelope change, a partial/garbage response, or a mocked response built with the wrong shape.
Common situations: Jike changes the cursor format in a new API version; tests or proxies return synthetic bodies with wrong cursor types; a mixed-version deployment where page 1 response differs from later pages.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Jike notifications API returned a malformed notification
- Jike notifications API returned a notification without a typ
- Jike notifications API returned a malformed action item
- Jike notifications API returned a malformed users list
- Jike notifications API returned a malformed user
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4abcfb2902935329.
Report an issue: GitHub.