{"record":{"id":"37b2a3080424323a","repo":"jackwener/OpenCLI","slug":"no-notifications-returned-for-noticelabel-suff","errorCode":null,"errorMessage":"No notifications returned for ${noticeLabel}${suffix}","messagePattern":"No notifications returned for (.+?)(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/tiktok/notifications.js","lineNumber":100,"sourceCode":"      for (const entry of list) {\n        const row = normalizeNotification(entry, dedup.size + 1);\n        if (row && !dedup.has(row.id)) dedup.set(row.id, row);\n      }\n      if (data.has_more !== true && data.hasMore !== true) break;\n      maxTime = asNumber(data.min_time) ?? asNumber(data.maxTime) ?? maxTime + list.length;\n    } catch (error) {\n      apiFailure = error instanceof Error ? error.message : String(error);\n      break;\n    }\n  }\n\n  const rows = Array.from(dedup.values())\n    .slice(0, limit)\n    .map((row, index) => ({ ...row, index: index + 1 }));\n\n  if (rows.length === 0) {\n    const suffix = apiFailure ? ' (notice API failed: ' + apiFailure + ')' : '';\n    throw new Error('No notifications returned for ' + noticeLabel + suffix);\n  }\n  return rows;\n})()\n`;\n}\n\nasync function listNotifications(page, args) {\n    const limit = requireLimit(args.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });\n    const typeKey = requireNotificationType(args.type);\n    await page.goto('https://www.tiktok.com/foryou', { waitUntil: 'load', settleMs: 5000 });\n    let rows;\n    try {\n        rows = await page.evaluate(buildNotificationsScript(limit, typeKey));\n    } catch (error) {\n        throwTikTokPageContextError(error, {\n            authMessage: 'TikTok requires login to read notifications',\n            emptyPattern: /No notifications returned/,\n            emptyTarget: 'tiktok notifications',","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/notifications.js#L82-L118","documentation":"The notifications command reads TikTok's notice API (all/activity-type notifications, selected via noticeLabel) and throws 'No notifications returned for <label>' when zero unique rows are collected. If a page fetch failed, the API error is appended as '(notice API failed: ...)' so callers can distinguish an API failure from an actually empty inbox.","triggerScenarios":"The notice endpoint returned an empty notification list for the selected label (e.g. no 'activities' notifications); the first page call failed via assertTikTokApiSuccess/fetchJson, setting apiFailure; missing msToken or an expired session causing rejected requests.","commonSituations":"Quiet account with genuinely no notifications of that type; TikTok rate-limiting the notice endpoint; login cookies expired so the API returns an auth/empty payload; region or account settings filtering out notification types.","solutions":["Check the '(notice API failed: ...)' suffix for the root API error and fix that first.","Re-login / refresh session cookies and msToken, then retry.","Wait and retry if rate-limited — the notice endpoint throttles automated polling.","Confirm in a browser that the notification tab shows entries for this label.","If the inbox is genuinely empty for that label, catch this error and treat it as an empty list."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isNotificationsEmpty(e) {\n  return e instanceof Error && e.message.startsWith('No notifications returned for');\n}\nfunction hadApiFailure(e) { return /notice API failed:/.test(e?.message || ''); }","tryCatchPattern":"try {\n  rows = await notificationsCommand({ limit });\n} catch (e) {\n  if (isNotificationsEmpty(e)) {\n    if (hadApiFailure(e)) await sleep(60_000); // retry after API failure\n    else rows = []; // inbox empty for this label\n  } else throw e;\n}","preventionTips":["Parse the notice-API failure suffix to separate API errors from empty inboxes","Refresh session cookies/msToken before long polling loops","Back off between notification polls to avoid notice-endpoint throttling","Confirm in the browser which notification labels actually have entries"],"tags":["tiktok","notifications","empty-result","api"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}