jackwener/OpenCLI · error · CommandExecutionError

Jike notifications API failed: ${String(body?.error || body?

Error message

Jike notifications API failed: ${String(body?.error || body?.message || 'malformed response')}

What it means

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.

Source

Thrown at clis/jike/notifications.js:89

        : '';
    const time = typeof notification.createdAt === 'string'
        ? notification.createdAt
        : (typeof notification.updatedAt === 'string' ? notification.updatedAt : '');
    return {
        type: resolveActionLabel(notification, actionItem),
        user: names.join('、'),
        content: cleanContent(actionItem.content || referenceContent),
        time,
    };
}

async function fetchNotificationsPage(page, loadMoreKey) {
    const body = await postJikeApi(page, API_PATH, {
        limit: PAGE_SIZE,
        ...(loadMoreKey ? { loadMoreKey } : {}),
    }, 'Jike notifications API');
    if (!body || typeof body !== 'object' || body.success === false || !Array.isArray(body.data)) {
        throw new CommandExecutionError(`Jike notifications API failed: ${String(body?.error || body?.message || 'malformed response')}`);
    }
    return body;
}

async function listNotifications(page, limit) {
    const rows = [];
    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;
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate / refresh the Jike credentials or session token
  2. Check the embedded error/message in the thrown error and inspect the raw response for details
  3. Retry after a delay if it is a rate-limit or transient outage (429/5xx)
  4. Update the CLI to match any Jike API envelope changes
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check session/auth before calling
if (!process.env.JIKE_TOKEN) throw new Error('JIKE_TOKEN not set');

Type guard

function isNotificationsBody(b) {
  return b !== null && typeof b === 'object' && b.success !== false && Array.isArray(b.data);
}

Try / catch

try {
  await cli('jike', 'notifications').run();
} catch (e) {
  if (String(e.message).startsWith('Jike notifications API failed:')) {
    await sleep(2000); // backoff then retry once
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/c27bfa4fde042f37. Report an issue: GitHub.