fix: fall back to search page when homepage lacks ondemand.s - #84
Open
gnuhpc wants to merge 1 commit into
Open
Conversation
X redesigned its homepage to use React Router (TSR), which no longer contains the ondemand.s file reference. This causes ClientTransaction init to fail, leading to 404s on search and other endpoints that require x-client-transaction-id header. The search page (x.com/search?q=AI&f=live) has NOT been redesigned and still uses the legacy responsive-web/client-web/ frontend with ondemand.s. This PR adds a fallback: if the homepage does not contain ondemand.s, automatically fetch the search page and use it for ClientTransaction initialization. Fixes public-clis#78, complements public-clis#79
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
X redesigned its homepage (
x.com) to use a new React Router (TSR) architecture. The new homepage no longer contains theondemand.sfile reference in its HTML, causingClientTransactioninitialization to fail. Without a valid transaction ID, endpoints that require thex-client-transaction-idheader (likeSearchTimeline) return HTTP 404.Related issues: #78, #73, #69
This PR complements #79 (which sends auth cookies with the homepage request) — but even with cookies, the redesigned homepage still lacks
ondemand.s.Root Cause
The
_ensure_client_transaction()method fetcheshttps://x.comand callsget_ondemand_file_url()to find theondemand.sJS file. Since the homepage redesign, this file reference is gone, soget_ondemand_file_url()returnsNone(after PR #79's fix) or crashes withAttributeError(before).However, the search page (
https://x.com/search?q=AI&f=live) has NOT been redesigned — it still uses the legacyresponsive-web/client-web/frontend and contains theondemand.sfile reference (232 occurrences in the HTML).Fix
Add a fallback in
_ensure_client_transaction(): if the homepage does not containondemand.s, automatically fetch the search page and use it forClientTransactioninitialization.Verification
ClientTransactioninitializes successfully via search page fallbacktwitter search "AI"returns results (was 404)Note
This PR only modifies
_ensure_client_transaction()— a minimal, focused change. The search page fallback is also documented in the XClientTransaction project (see PR #44 and #45).