jackwener/OpenCLI · warning · EmptyResultError

twitter following

Error message

twitter following

What it means

EmptyResultError with operation 'twitter following' thrown when the target account's following list appears private: the response matches looksLikePrivateTwitterTimeline, meaning Twitter returned an empty/timeline-like payload because the following list is not visible to you. The library surfaces this explicitly instead of reporting a silent empty result.

Source

Thrown at clis/twitter/following.js:240

                    throw new AuthRequiredError('x.com', `Twitter following request failed (HTTP ${data.error})`);
                throw new CommandExecutionError(describeTwitterApiError('Following', data.error));
            }
            lastRawResponse = data;
            const { users, nextCursor } = parseFollowing(data);
            for (const u of users) {
                if (!seen.has(u.screen_name)) {
                    seen.add(u.screen_name);
                    allUsers.push(u);
                }
            }
            if (!nextCursor || nextCursor === cursor)
                break;
            cursor = nextCursor;
        }

        if (allUsers.length === 0) {
            if (looksLikePrivateTwitterTimeline(lastRawResponse)) {
                throw new EmptyResultError('twitter following', `No following data returned for @${targetUser} (the target account may have set their following list to private)`);
            }
            throw new EmptyResultError('twitter following', `No following accounts found for @${targetUser}`);
        }

        return allUsers.slice(0, limit);
    },
});

export const __test__ = {
    sanitizeQueryId,
    buildFollowingUrl,
    extractUser,
    normalizeScreenName,
    parseFollowing,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Follow the target account from the CLI's logged-in x.com session, then re-run
  2. Confirm in a browser at x.com/<name>/following whether the list is visible to your account
  3. Use an account that has permission to view that following list
  4. Accept the limitation: protected accounts' following lists are intentionally hidden

Example fix

// before: private following list, non-follower session
Error: twitter following — No following data returned for @privateuser (the target account may have set their following list to private)
// after: follow the account with the session user first, then retry
$ opencli twitter follow @privateuser && opencli twitter following @privateuser
Defensive patterns

Strategy: try-catch

Validate before calling

// Only request following lists you can see
async function canViewFollowing(page, handle) {
  return page.evaluate(async (h) => {
    const r = await fetch(`https://x.com/${h}`, { credentials: 'include' });
    return r.ok;
  }, handle);
}
if (!(await canViewFollowing(page, target))) throw new Error('Account unavailable to your session');

Type guard

function isPrivateListError(err) {
  return err && err.name === 'EmptyResultError' && /following list to private/.test(err.message);
}

Try / catch

try {
  const users = await cli.following(target);
} catch (err) {
  if (isPrivateListError(err)) {
    console.warn(`${target} keeps their following list private; skipping.`);
    return [];
  }
  throw err;
}

Prevention

When it happens

Trigger: Pagination completed (or first page) with zero users parsed AND lastRawResponse matches the private-timeline heuristic: requesting the following list of an account that hides it from non-followers, while your session is not an approved follower.

Common situations: Scraping a private/protected account's following list; viewing an account that restricts following visibility to mutuals/followers; being logged out (or as a non-follower) when the list is follower-only.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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