{"record":{"id":"bb5454644f6f41c0","repo":"jackwener/OpenCLI","slug":"no-friend-suggestions-returned-by-tiktok-suffix","errorCode":null,"errorMessage":"No friend suggestions returned by TikTok + suffix","messagePattern":"No friend suggestions returned by TikTok \\+ suffix","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/tiktok/friends.js","lineNumber":100,"sourceCode":"          const row = normalizeUserRow(entry?.user || entry, dedup.size + 1);\n          if (row && !dedup.has(row.username)) dedup.set(row.username, row);\n        }\n        if (data.hasMore !== true) break;\n        cursor = asNumber(data.cursor) ?? cursor + list.length;\n      } catch (error) {\n        apiFailure = error instanceof Error ? error.message : String(error);\n        break;\n      }\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 ? ' (recommend-user API failed: ' + apiFailure + ')' : '';\n    throw new Error('No friend suggestions returned by TikTok' + suffix);\n  }\n  return rows;\n})()\n`;\n}\n\nasync function listFriends(page, args) {\n    const limit = requireLimit(args.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });\n    await page.goto('https://www.tiktok.com/friends', { waitUntil: 'load', settleMs: 5000 });\n    let rows;\n    try {\n        rows = await page.evaluate(buildFriendsScript(limit));\n    } catch (error) {\n        throwTikTokPageContextError(error, {\n            authMessage: 'TikTok requires browser access to load friend suggestions',\n            emptyPattern: /No friend suggestions/,\n            emptyTarget: 'tiktok friends',\n            failureMessage: 'Failed to load TikTok friend suggestions',","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/friends.js#L82-L118","documentation":"The friends command pages TikTok's recommend-user API for friend suggestions; if no unique suggestion rows are collected, it throws 'No friend suggestions returned by TikTok'. When a page fetch failed, the API error is appended as '(recommend-user API failed: ...)' so callers can see why suggestions were empty.","triggerScenarios":"The recommend-user endpoint returned an empty list (no suggestions generated for the account); the first API call failed (assertTikTokApiSuccess threw) setting apiFailure; msToken/signature issues causing rejected requests.","commonSituations":"Fresh or low-activity accounts with no friend suggestions; TikTok rate-limiting the recommend endpoint from automation; logged-out or semi-logged-in state producing empty recommendation payloads.","solutions":["Inspect the '(recommend-user API failed: ...)' suffix for the root API error and fix that first.","Refresh cookies/msToken by logging in normally and retrying.","Retry after a delay — recommendation endpoints are rate-limited and often recover.","Confirm in a browser that tiktok.com shows friend suggestions for this account.","If the account has no suggestions, catch this error and treat it as an empty list."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isFriendsEmpty(e) {\n  return e instanceof Error && e.message.startsWith('No friend suggestions returned by TikTok');\n}\nfunction hadApiFailure(e) { return /recommend-user API failed:/.test(e?.message || ''); }","tryCatchPattern":"try {\n  rows = await friendsCommand({ limit });\n} catch (e) {\n  if (isFriendsEmpty(e)) {\n    if (hadApiFailure(e)) await sleep(60_000); // retry after API failure\n    else rows = []; // no suggestions for this account\n  } else throw e;\n}","preventionTips":["Read the recommend-user failure suffix before retrying","Refresh cookies/msToken when the suffix shows API errors","Retry after delay — recommendations are rate-limited and time-varying","Handle genuinely suggestion-less accounts as empty, not fatal"],"tags":["tiktok","empty-result","recommendations","api"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}