Skip to content

fix(twitter): drop 'unknown' silent sentinel in search/notifications/following row fields#1776

Open
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/twitter-silent-sentinels
Open

fix(twitter): drop 'unknown' silent sentinel in search/notifications/following row fields#1776
Benjamin-eecs wants to merge 1 commit into
jackwener:mainfrom
Benjamin-eecs:fix/twitter-silent-sentinels

Conversation

@Benjamin-eecs
Copy link
Copy Markdown
Contributor

Description

Three twitter read commands fall back to the string 'unknown' when upstream omits the user's screen_name or display name. The result row then masks the missing-value signal: an agent cannot tell apart a real user whose handle is literally unknown from 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 screenName is interpolated into the result row's url: \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

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

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 contains core.user_results.result.core.screen_name produce the same author value.

opencli twitter notifications --limit 3 --format yaml: populated rows on both. The first entry unusual_whales continues to round-trip through the populated-screen-name path.

opencli twitter following Benjamin_eecs --limit 3 --format yaml: populated rows on both. The seen.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.js adds surfaces empty screen_name and name when upstream omits both against extractUser
  • clis/twitter/search.test.js adds surfaces empty author when the tweet has no user screen_name against parseSearchTimeline
  • clis/twitter/notifications.js swap 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.

…following row fields

Distinguishes "upstream returned no value" from a real user named 'unknown'.

Fixes jackwener#1775
@Benjamin-eecs Benjamin-eecs force-pushed the fix/twitter-silent-sentinels branch from ddbe7f7 to 95d520d Compare May 28, 2026 12:30
@Benjamin-eecs Benjamin-eecs marked this pull request as ready for review May 28, 2026 12:32
Copilot AI review requested due to automatic review settings May 28, 2026 12:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: '' when screen_name is absent.
  • Update notifications and following parsing to default missing screen_name/name to ''.
  • 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.

Comment thread clis/twitter/search.js
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 thread clis/twitter/following.js
Comment on lines +94 to +95
screen_name: core.screen_name || legacy.screen_name || '',
name: core.name || legacy.name || '',
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.

[Bug]: twitter search/notifications/following surface 'unknown' silent sentinel instead of empty string on missing user fields

2 participants