Skip to content

Remove retweeted original tweet from the list of tweets, fixes #310#311

Merged
vladkens merged 3 commits into
vladkens:mainfrom
Flaburgan:310-doubled-retweets
Jun 8, 2026
Merged

Remove retweeted original tweet from the list of tweets, fixes #310#311
vladkens merged 3 commits into
vladkens:mainfrom
Flaburgan:310-doubled-retweets

Conversation

@Flaburgan

Copy link
Copy Markdown
Contributor

get_typed_objectinutils.pyis a recursive deep-walker that collects **all** objects with a__typenamefield anywhere in the API response. When Twitter returns a retweet, the retweeted tweet is nested insideretweeted_status_result.resultand also carries__typename: "Tweet". It therefore ends up in the flat tweetsdict built byto_old_rep, and _parse_items` then yields every entry in that dict without distinguishing top-level timeline items from nested lookup objects.

The nested tweet is legitimately needed in res["tweets"] as a lookup so Tweet.parse() can populate retweetedTweet. The bug is that _parse_items has no way to know which entries are top-level vs. which were collected as nested references.

Expected behaviour

user_tweets should yield the RT wrapper once. The original tweet should only be accessible via tweet.retweetedTweet, not as a separate item in the iteration.

Note

The bug existed conceptually since 9238398 (July 2023, the commit that introduced retweetedTweet support), but likely only became reliably reproducible after the May 2026 schema change: the old Twitter schema may not have included a legacy key on the nested retweeted object, which was the filter gate ([x for x in tmp["Tweet"] if "legacy" in x]). The schema migration explicitly preserves that filter condition, causing nested tweets to now consistently pass through.

@Flaburgan Flaburgan force-pushed the 310-doubled-retweets branch from e36fd7a to e665979 Compare June 1, 2026 11:06
@vladkens vladkens force-pushed the 310-doubled-retweets branch from 8e1103f to eb21c19 Compare June 8, 2026 17:36
@vladkens vladkens merged commit 47ba106 into vladkens:main Jun 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants