{"record":{"id":"c27bfa4fde042f37","repo":"jackwener/OpenCLI","slug":"jike-notifications-api-failed-string-body-erro","errorCode":null,"errorMessage":"Jike notifications API failed: ${String(body?.error || body?.message || 'malformed response')}","messagePattern":"Jike notifications API failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/jike/notifications.js","lineNumber":89,"sourceCode":"        : '';\n    const time = typeof notification.createdAt === 'string'\n        ? notification.createdAt\n        : (typeof notification.updatedAt === 'string' ? notification.updatedAt : '');\n    return {\n        type: resolveActionLabel(notification, actionItem),\n        user: names.join('、'),\n        content: cleanContent(actionItem.content || referenceContent),\n        time,\n    };\n}\n\nasync function fetchNotificationsPage(page, loadMoreKey) {\n    const body = await postJikeApi(page, API_PATH, {\n        limit: PAGE_SIZE,\n        ...(loadMoreKey ? { loadMoreKey } : {}),\n    }, 'Jike notifications API');\n    if (!body || typeof body !== 'object' || body.success === false || !Array.isArray(body.data)) {\n        throw new CommandExecutionError(`Jike notifications API failed: ${String(body?.error || body?.message || 'malformed response')}`);\n    }\n    return body;\n}\n\nasync function listNotifications(page, limit) {\n    const rows = [];\n    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        }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jike/notifications.js#L71-L107","documentation":"fetchNotificationsPage posts to the Jike notifications API and requires a body that is an object with success !== false and a `data` array. Anything else (null body, non-object, success:false, missing data array) is treated as an API failure and wrapped in CommandExecutionError, including whatever error/message the server supplied.","triggerScenarios":"The Jike notifications endpoint returns success:false with an error message, an HTML error page instead of JSON, a 200 response missing the data array, rate-limit responses, or auth-expiry payloads that lack the expected envelope.","commonSituations":"Expired or revoked Jike session token, Jike rate limiting, Jike API outage or maintenance, network proxy returning an HTML error page, Jike changing the response envelope in a new API version.","solutions":["Re-authenticate / refresh the Jike credentials or session token","Check the embedded error/message in the thrown error and inspect the raw response for details","Retry after a delay if it is a rate-limit or transient outage (429/5xx)","Update the CLI to match any Jike API envelope changes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check session/auth before calling\nif (!process.env.JIKE_TOKEN) throw new Error('JIKE_TOKEN not set');","typeGuard":"function isNotificationsBody(b) {\n  return b !== null && typeof b === 'object' && b.success !== false && Array.isArray(b.data);\n}","tryCatchPattern":"try {\n  await cli('jike', 'notifications').run();\n} catch (e) {\n  if (String(e.message).startsWith('Jike notifications API failed:')) {\n    await sleep(2000); // backoff then retry once\n  } else throw e;\n}","preventionTips":["Refresh Jike credentials before long-running jobs","Add exponential backoff for 429/5xx responses","Monitor Jike API status for outages"],"tags":["network","api-response","jike"],"backgroundTag":"api-error-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}