{"record":{"id":"4abcfb2902935329","repo":"jackwener/OpenCLI","slug":"jike-notifications-api-returned-a-malformed-pagina","errorCode":null,"errorMessage":"Jike notifications API returned a malformed pagination cursor","messagePattern":"Jike notifications API returned a malformed pagination cursor","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jike/notifications.js","lineNumber":114,"sourceCode":"    const seenIds = new Set();\n    const seenCursors = new Set();\n    let loadMoreKey = null;\n    for (let pageIndex = 0; pageIndex < MAX_PAGES; pageIndex++) {\n        const body = await fetchNotificationsPage(page, loadMoreKey);\n        for (const notification of body.data) {\n            const row = mapNotification(notification);\n            if (seenIds.has(notification.id)) continue;\n            seenIds.add(notification.id);\n            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 notifications', 'No notifications found');\n            return rows;\n        }\n        if (typeof next !== 'object' || Array.isArray(next)) {\n            throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');\n        }\n        const cursorKey = JSON.stringify(next);\n        if (seenCursors.has(cursorKey)) {\n            throw new CommandExecutionError('Jike notifications pagination returned a repeated cursor');\n        }\n        seenCursors.add(cursorKey);\n        loadMoreKey = next;\n    }\n    throw new CommandExecutionError(`Jike notifications pagination exceeded ${MAX_PAGES} pages before satisfying --limit`);\n}\n\ncli({\n    site: 'jike',\n    name: 'notifications',\n    access: 'read',\n    description: '即刻通知',\n    domain: 'web.okjike.com',\n    strategy: Strategy.COOKIE,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jike/notifications.js#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nif (typeof next !== 'object' || Array.isArray(next)) {\n  throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');\n}\n// after\nconst normalizedNext = typeof next === 'string' || typeof next === 'number'\n  ? { loadMoreKey: next }\n  : next;\nif (!normalizedNext || typeof normalizedNext !== 'object' || Array.isArray(normalizedNext)) {\n  throw new CommandExecutionError('Jike notifications API returned a malformed pagination cursor');\n}","handlingStrategy":"validation","validationCode":"// validate the response envelope before paginating\nfunction cursorIsUsable(body) {\n  const c = body?.loadMoreKey;\n  return c == null || (typeof c === 'object' && !Array.isArray(c));\n}","typeGuard":"function isCursor(c) {\n  return c !== null && typeof c === 'object' && !Array.isArray(c);\n}","tryCatchPattern":"try {\n  await cli('jike', 'notifications').run();\n} catch (e) {\n  if (String(e.message).includes('malformed pagination cursor')) {\n    // pin an older API behavior or report/update the CLI\n  } else throw e;\n}","preventionTips":["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"],"tags":["pagination","schema-validation","jike"],"backgroundTag":"invalid-pagination-cursor","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}