{"record":{"id":"ce08809fd7bf6d98","repo":"jackwener/OpenCLI","slug":"tiktok-returned-no-friend-suggestions","errorCode":null,"errorMessage":"TikTok returned no friend suggestions","messagePattern":"TikTok returned no friend suggestions","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/tiktok/friends.js","lineNumber":122,"sourceCode":"`;\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',\n        });\n    }\n    if (!Array.isArray(rows) || rows.length === 0) {\n        throw new EmptyResultError('tiktok friends', 'TikTok returned no friend suggestions');\n    }\n    return rows;\n}\n\nexport const friendsCommand = cli({\n    site: 'tiktok',\n    name: 'friends',\n    access: 'read',\n    description: 'Get TikTok friend / who-to-follow suggestions via page-context APIs',\n    domain: 'www.tiktok.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of suggestions (max ${MAX_LIMIT})` },\n    ],\n    columns: ['index', 'username', 'name', 'secUid', 'verified', 'followers', 'following', 'url'],\n    func: listFriends,\n});","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/friends.js#L104-L140","documentation":"listFriends' final guard: if rows is not a non-empty array after the page script completes, it throws EmptyResultError('tiktok friends', 'TikTok returned no friend suggestions'). This ensures the command fails with a typed empty-result error rather than returning an empty success value.","triggerScenarios":"The page script returned null/undefined or an empty array — TikTok's recommend-user API returned zero suggestions or the request path silently degraded.","commonSituations":"Accounts TikTok has no suggestions for; TikTok experiments returning empty recommendation payloads; a bug/regression where the script returns a non-array.","solutions":["Catch EmptyResultError and default to an empty suggestions list in your code.","Verify in a browser whether tiktok.com actually shows suggestions for this account.","Refresh the login session and retry — recommendation quality depends on a valid session.","Upgrade the library if TikTok changed the recommend-user response shape.","Treat a consistent empty result for an active account as a signal to check for rate limiting or region blocks."],"exampleFix":"// before\nconst rows = await friendsCommand({ limit: 20 });\n// after\ntry {\n  rows = await friendsCommand({ limit: 20 });\n} catch (e) {\n  if (e instanceof EmptyResultError) rows = [];\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isEmptyResult(e) {\n  return e instanceof EmptyResultError;\n}","tryCatchPattern":"let rows = [];\ntry {\n  rows = await friendsCommand({ limit });\n} catch (e) {\n  if (e instanceof EmptyResultError) rows = [];\n  else throw e;\n}","preventionTips":["Default to an empty suggestion list on EmptyResultError","Verify suggestion availability in a real browser session for the same account","Keep the library current against TikTok recommend-user payload changes","Check session validity if empties become persistent"],"tags":["tiktok","empty-result","emptyresulterror"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}