Fix undefined user ids in parseTweet by falling back to rest_id#1311
Merged
dimdenGD merged 1 commit intoJun 10, 2026
Merged
Conversation
X no longer includes legacy user id fields (user_id_str on the tweet, id_str on the user) in some GraphQL responses such as HomeTimeline, while TweetDetail still has them. parseTweet relied on those fields alone, so tweets parsed from the home timeline ended up with user.id_str === undefined, breaking every action that sends the author id (report, block, mute, copy user id) and poisoning the userStorage cache key. Fall back to user_results.result.rest_id, the canonical id that is always present, in all five user id assignments (main tweet, retweeted status, quoted status, and quotes inside retweets). Legacy fields still take precedence when present, matching the user.legacy.id_str = rest_id pattern already used elsewhere in apis.js. Assisted-by: Claude Fable 5 with Claude Code
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.
Summary
X no longer includes the legacy user id fields (
user_id_stron the tweet legacy,id_stron the user legacy) in some GraphQL responses such asHomeTimeline, whileTweetDetailstill has them.parseTweetrelied on those fields alone, so tweets parsed from the home timeline end up withuser.id_str === undefined.This silently breaks every action that sends the author id from the timeline — block, mute, copy user ID — and poisons the
userStoragecache with anundefinedkey.Fix
Fall back to
user_results.result.rest_id(the canonical id that is always present in GraphQL responses) in all five user id assignments inparseTweet: main tweet, retweeted status, quoted status, and quotes inside retweets. The legacy fields still take precedence when present, so endpoints that still send them (e.g.TweetDetail) are unaffected. This matches theuser.legacy.id_str = user.rest_idpattern already used elsewhere inapis.js.Test plan
parseTweetagainst fixtures with and without the legacy id fields: without them, all user ids previously came outundefinedand now resolve torest_id; with them, the legacy values still win.t.user.id_strreceive a real user id again.🤖 Generated with Claude Code