Skip to content

fix(graphql): refresh FALLBACK_QUERY_IDS against live twitter-openapi IDs (complements #79/#80) - #82

Open
zaprogrammer wants to merge 1 commit into
public-clis:mainfrom
zaprogrammer:fix/refresh-fallback-query-ids
Open

fix(graphql): refresh FALLBACK_QUERY_IDS against live twitter-openapi IDs (complements #79/#80)#82
zaprogrammer wants to merge 1 commit into
public-clis:mainfrom
zaprogrammer:fix/refresh-fallback-query-ids

Conversation

@zaprogrammer

Copy link
Copy Markdown

Problem

tw search, tw feed, tw bookmarks, and most other read commands currently fail with HTTP 404 / Query: Unspecified against live X.

Root cause: X rotated nearly all GraphQL queryIds. The hardcoded FALLBACK_QUERY_IDS in twitter_cli/graphql.py have drifted (both the 0.8.5 release and current main are stale), so every request that depends on a fallback ID is rejected.

User-visible symptom reported in #78: twitter search returns 404 even with valid cookies, even with PRs #79 + #80 applied (those fix the x-client-transaction-id init; the queryId itself is also stale).

Fix

Refreshed 15 of 22 fallback IDs against the community-maintained twitter-openapi placeholder.json — the same source _fetch_from_github() already trusts at runtime (twitter_cli/graphql.py:TWITTER_OPENAPI_URL). So this is a snapshot of exactly what dynamic resolution would have fetched, just with the network call removed.

Ops rotated (stale → live):

Op Status
HomeTimeline, HomeLatestTimeline, UserByScreenName, UserTweets, TweetDetail, Likes rotated
SearchTimeline rotated (this is the one in #78)
Bookmarks, ListLatestTweetsTimeline, Followers, Following rotated
CreateTweet, CreateRetweet, DeleteRetweet, TweetResultByRestId rotated
DeleteTweet, FavoriteTweet, UnfavoriteTweet, CreateBookmark, DeleteBookmark unchanged
BookmarkFoldersSlice, BookmarkFolderTimeline no live value in upstream; kept as-is

Verification

End-to-end on a live account (cookies from ~/.agent-reach/twitter.env):

$ tw search "AI agents" --json -n 5 --type latest --since 2026-08-02
rc: 0, ok: true          ← previously: rc:1, HTTP 404

Test suite on this branch:

$ pytest tests/test_client.py
86 passed in 7.60s

tests/test_client.py::test_searchtimeline_fallback_query_id_regression updated to pin the new live ID — its original value (VhUd6vHVmLBcw0uX-6jMLA) was itself stale.

Relation to open PRs

Both are needed for tw search to work — with only #79/#80 you'd get 404 on a stale queryId; with only this PR you'd get rejected for a missing/invalid transaction ID. I applied both locally to verify tw search end-to-end, but they review independently — whichever lands first unblocks half the failure, the second one finishes it.

Follow-up (not in this PR)

X rotates these IDs on a regular cadence. Long-term, consider seeding _cached_query_ids from the runtime-fetched placeholder.json before falling back to the hardcoded dict — currently _resolve_query_id(prefer_fallback=True) (the default) returns the hardcoded value immediately and never consults the live source, which is how this drift persisted. Added a comment atop FALLBACK_QUERY_IDS with the refresh URL.

… IDs

X rotated most GraphQL queryIds; stale fallbacks caused persistent HTTP 404
on search, timelines, bookmarks, etc. (see issue public-clis#78). Both the installed
release (0.8.5) and main had drifted.

Refreshes 15 of 22 fallback IDs from the community-maintained
twitter-openapi placeholder.json (the same source _fetch_from_github already
trusts at runtime). Updates the SearchTimeline regression test to pin the
new live ID and adds a comment explaining when/how to refresh.

Verified end-to-end on a live account: 'tw search "AI agents" --json'
returns ok:true with fresh tweets after this change; test suite 86/86.

Complements public-clis#79 / public-clis#80 (ClientTransaction init on /home): those fix the
x-client-transaction-id side; this fixes the stale queryId side. Search
needs both.
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.

1 participant