fix(graphql): refresh FALLBACK_QUERY_IDS against live twitter-openapi IDs (complements #79/#80) - #82
Open
zaprogrammer wants to merge 1 commit into
Conversation
… 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.
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.
Problem
tw search,tw feed,tw bookmarks, and most other read commands currently fail withHTTP 404/Query: Unspecifiedagainst live X.Root cause: X rotated nearly all GraphQL
queryIds. The hardcodedFALLBACK_QUERY_IDSintwitter_cli/graphql.pyhave drifted (both the 0.8.5 release and currentmainare stale), so every request that depends on a fallback ID is rejected.User-visible symptom reported in #78:
twitter searchreturns 404 even with valid cookies, even with PRs #79 + #80 applied (those fix thex-client-transaction-idinit; the queryId itself is also stale).Fix
Refreshed 15 of 22 fallback IDs against the community-maintained
twitter-openapiplaceholder.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):
Verification
End-to-end on a live account (cookies from
~/.agent-reach/twitter.env):Test suite on this branch:
tests/test_client.py::test_searchtimeline_fallback_query_id_regressionupdated to pin the new live ID — its original value (VhUd6vHVmLBcw0uX-6jMLA) was itself stale.Relation to open PRs
/homewith auth cookies for ClientTransaction init): fixes thex-client-transaction-idheader side.Both are needed for
tw searchto work — with only #79/#80 you'd get404on a stale queryId; with only this PR you'd get rejected for a missing/invalid transaction ID. I applied both locally to verifytw searchend-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_idsfrom the runtime-fetchedplaceholder.jsonbefore 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 atopFALLBACK_QUERY_IDSwith the refresh URL.