fix(twitter/profile): recover counts + bio after X relocates them out of legacy (#2188) - #2193
Merged
jackwener merged 2 commits intoJul 29, 2026
Conversation
LeoLin990405
force-pushed
the
fix/twitter-profile-relocated-fields
branch
from
July 28, 2026 05:53
9fbf21b to
d40e0d9
Compare
… of legacy (jackwener#2188) `twitter profile` returned followers/following/tweets/likes = 0 and an empty bio while name/screen_name/created_at/verified stayed correct. X moved the count fields (followers_count/friends_count/statuses_count/favourites_count) and the bio (description) out of `result.legacy` into a new container — the same drift jackwener#1745 handled for name/created_at by reading `result.core`. Rather than hard-code the (unknown) new path, resolve each field from its known homes first (legacy → core → top-level result), then fall back to a bounded breadth-first search that returns the shallowest match. The BFS refuses to cross into containers describing a *different* entity (pinned_tweet, entities, media, …) so it can never report an embedded tweet's favourites_count as the user's likes or its text as the bio — a wrong-but-confident value would be worse than 0 / ''. This restores the counts/bio today and stays robust if X relocates them again. Legacy-path responses resolve identically (existing test unchanged). Adds offline regression tests for the relocated-field case, legacy precedence over a deeper decoy, the embedded-tweet guard, all-missing fallbacks, and resolver type/empty handling.
jackwener
force-pushed
the
fix/twitter-profile-relocated-fields
branch
from
July 29, 2026 11:54
d40e0d9 to
8e7ae7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem — #2188
opencli twitter profile <user>returnsfollowers,following,tweets,likesall 0 and an emptybio, whilename/screen_name/created_at/verifiedare correct.Root cause: X (Twitter) relocated the count fields (
followers_count,friends_count,statuses_count,favourites_count) and the bio (description) out ofresult.legacyinto a new container — the same schema drift #1745 already handled forname/created_atby readingresult.core. The adapter still read the counts and bio only fromresult.legacy, so they silently fell back to0/''.Fix
Rather than hard-code the (unknown, still-shifting) new path,
mapTwitterProfileResultnow resolves each affected field from its known homes first (legacy→core→ top-levelresult), then falls back to a bounded breadth-first search that returns the shallowest match.Shallowest-wins alone is not safe: when the field is absent from the user object entirely, an unrestricted BFS would descend into an embedded tweet and report its
favourites_countas the user's likes, or its text as the bio. So the search refuses to cross into containers that describe a different entity (pinned_tweet,tweet,status,quoted_status,retweeted_status,entities,extended_entities,media,highlights). A wrong-but-confident number is worse than0/''.result.legacy) resolve identically — the existing test is unchanged.Tests
mapTwitterProfileResultis a pure exported function. Added offline regression tests (12 total in the file):legacy(the [Bug]: twitter/profile returns 0 for followers/following/tweets/likes and empty bio (regression, opposite of #1745) #2188 case)legacyvalues still win over a deeper decoy occurrence0/''0/''No change to the
cli()registration, socli-manifest.jsonis untouched.