Fetch homepage authenticated for ClientTransaction init - #89
Open
GodfreyPrince wants to merge 1 commit into
Open
Fetch homepage authenticated for ClientTransaction init#89GodfreyPrince wants to merge 1 commit into
GodfreyPrince wants to merge 1 commit into
Conversation
The logged-out x.com homepage no longer embeds the ondemand chunk map or loading-x-anim frames that xclienttransaction parses, so the anonymous fetch in _ensure_client_transaction always failed init and no x-client-transaction-id header was ever generated. The search endpoint rejects such requests with HTTP 404 even with a fresh live queryId, while feed/user endpoints kept working. Send the account Cookie + X-Csrf-Token with the init fetch so the logged-in page (which contains all three markers) is parsed instead.
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
twitter search(and any endpoint requiringx-client-transaction-id) fails with HTTP 404, even with a fresh liveSearchTimelinequeryId from the community openapi file.Root cause
_ensure_client_transactionfetcheshttps://x.comanonymously. The logged-out homepage no longer embeds either artifactxclienttransactionparses:ondemand.*webpack chunk map (ON_DEMAND_FILE_REGEXfinds nothing, so.group(1)raisesNoneType has no attribute group, swallowed as a warning), andloading-x-animSVG frames.So
ClientTransactionnever initializes, nox-client-transaction-idheader is ever sent, and the search endpoint 404s every request. Feed/user endpoints do not require the header, which is why only search broke.Fix
Send the account
Cookie+X-Csrf-Tokenwith the init fetch. The logged-in homepage contains the chunk map, the animation frames, and thetwitter-site-verificationmeta, so init succeeds.Verified end-to-end on Windows (Brave 152, Python 3.13): the
Failed to init ClientTransactionwarning is gone andtwitter search "AI agent" -t Latestreturnsok: true.