Skip to content

Fix undefined user ids in parseTweet by falling back to rest_id#1311

Merged
dimdenGD merged 1 commit into
dimdenGD:masterfrom
teslamint:fix/parsetweet-user-id-fallback
Jun 10, 2026
Merged

Fix undefined user ids in parseTweet by falling back to rest_id#1311
dimdenGD merged 1 commit into
dimdenGD:masterfrom
teslamint:fix/parsetweet-user-id-fallback

Conversation

@teslamint

Copy link
Copy Markdown
Contributor

Summary

X no longer includes the legacy user id fields (user_id_str on the tweet legacy, id_str on the user legacy) 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 end up with user.id_str === undefined.

This silently breaks every action that sends the author id from the timeline — block, mute, copy user ID — and poisons the userStorage cache with an undefined key.

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 in parseTweet: 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 the user.legacy.id_str = user.rest_id pattern already used elsewhere in apis.js.

Test plan

  • Unit-tested parseTweet against fixtures with and without the legacy id fields: without them, all user ids previously came out undefined and now resolve to rest_id; with them, the legacy values still win.
  • Verified on the home timeline that actions using t.user.id_str receive a real user id again.

🤖 Generated with Claude Code

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
@dimdenGD dimdenGD merged commit e6a7e68 into dimdenGD:master Jun 10, 2026
2 checks passed
@teslamint teslamint deleted the fix/parsetweet-user-id-fallback branch June 10, 2026 10:49
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