fix(twitter): drop 'unknown' silent sentinel in search/notifications/following row fields#1776
Open
Benjamin-eecs wants to merge 1 commit into
Open
Conversation
…following row fields Distinguishes "upstream returned no value" from a real user named 'unknown'. Fixes jackwener#1775
ddbe7f7 to
95d520d
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR changes Twitter CLI parsing to surface missing user identity fields (author/screen_name/name) as empty strings instead of the literal "unknown", and adds tests to lock in the new behavior.
Changes:
- Update search tweet parsing to return
author: ''whenscreen_nameis absent. - Update notifications and following parsing to default missing
screen_name/nameto''. - Add unit tests covering upstream payloads that omit these fields.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| clis/twitter/search.js | Changes tweet row author fallback from "unknown" to empty string. |
| clis/twitter/search.test.js | Adds a test ensuring empty author when upstream lacks screen_name. |
| clis/twitter/notifications.js | Changes notification author fallback from "unknown" to empty string in multiple branches. |
| clis/twitter/following.js | Changes extracted user screen_name/name fallbacks to empty strings. |
| clis/twitter/following.test.js | Adds a test ensuring missing screen_name/name become empty strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return { | ||
| id: tweet.rest_id, | ||
| author: tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || 'unknown', | ||
| author: tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || '', |
| let item = itemContent?.notification_results?.result || itemContent?.tweet_results?.result || itemContent; | ||
| let actionText = 'Notification'; | ||
| let author = 'unknown'; | ||
| let author = ''; |
| const fromUser = item.template?.from_users?.[0]?.user_results?.result; | ||
| // Twitter moved screen_name from legacy to core | ||
| author = fromUser?.core?.screen_name || fromUser?.legacy?.screen_name || 'unknown'; | ||
| author = fromUser?.core?.screen_name || fromUser?.legacy?.screen_name || ''; |
| const tweet = item.tweet_result?.result; | ||
| const tweetUser = tweet?.core?.user_results?.result; | ||
| author = tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || 'unknown'; | ||
| author = tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || ''; |
| else if (item.__typename === 'Tweet') { | ||
| const tweetUser = item.core?.user_results?.result; | ||
| author = tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || 'unknown'; | ||
| author = tweetUser?.core?.screen_name || tweetUser?.legacy?.screen_name || ''; |
Comment on lines
+94
to
+95
| screen_name: core.screen_name || legacy.screen_name || '', | ||
| name: core.name || legacy.name || '', |
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.
Description
Three twitter read commands fall back to the string
'unknown'when upstream omits the user'sscreen_nameor display name. The result row then masks the missing-value signal: an agent cannot tell apart a real user whose handle is literallyunknownfrom a row where the screen_name was absent in the GraphQL payload. Continuing the silent-sentinel sweep direction from #1611 (lesswrong) / #1631 (wikipedia, 36kr, xiaoyuzhou, zhihu, douyin, jike) / #1634 (apple-podcasts, reddit, gitee), flip the sentinel to''only on the display-only sites where the sentinel is not consumed in URL substrate or downstream control flow.Scope is intentionally narrow: tweets/thread/bookmarks/article/timeline/likes/list-tweets keep the sentinel because
screenNameis interpolated into the result row'surl: \https://x.com/${screenName}/status/${rest_id}\``, where''would produce a malformed URL. accept/reply-dm are write commands and belong to a follow-up where the account owner runs the live test. utils.js error-string interpolation and download.js classifier-return are owner's #1634 explicit baseline exclusions.Related issue: fixes #1775.
Type of Change
Checklist
Screenshots / Output
Live before/after on this branch (logged-in twitter session):
opencli twitter search "opencli" --limit 3 --format yaml: populated rows on both before and after; rows whose tweet payload containscore.user_results.result.core.screen_nameproduce the sameauthorvalue.opencli twitter notifications --limit 3 --format yaml: populated rows on both. The first entryunusual_whalescontinues to round-trip through the populated-screen-name path.opencli twitter following Benjamin_eecs --limit 3 --format yaml: populated rows on both. Theseen.has(u.screen_name)dedup behavior is unchanged because rows whose screen_name was previously'unknown'and rows whose screen_name is now''both collapse to one row under the same dedup logic.Unit tests cover the empty-signal branch:
clis/twitter/following.test.jsaddssurfaces empty screen_name and name when upstream omits bothagainstextractUserclis/twitter/search.test.jsaddssurfaces empty author when the tweet has no user screen_nameagainstparseSearchTimelineclis/twitter/notifications.jsswap lives inside a closure called from the interceptor processor; coverage follows owner's fix(adapters): drop silent-sentinel row fallbacks across Apple Podcasts, Reddit, and Gitee #1634 pattern for in-evaluate swaps (semantics demonstrated by the sibling extractUser/parseSearchTimeline tests above)Full twitter suite: 368/368 pass on this branch.