fix: send auth cookies when fetching x.com home for ClientTransaction init (fixes #78) - #79
Open
CumartesiKahvesi wants to merge 1 commit into
Conversation
… init _ensure_client_transaction() fetched https://x.com with a fresh, unauthenticated curl_cffi session (no cookies). Since Aug 2026, the logged-out x.com response no longer contains the ,<id>:"ondemand.s" webpack chunk marker that get_ondemand_file_url() looks for, so ClientTransaction init silently fails (caught by the broad except in _ensure_client_transaction) and the client falls back to a stale hardcoded SearchTimeline queryId, which Twitter now 404s on. Fetching https://x.com/home with the session's own auth_token/ct0 cookies returns the authenticated app shell, which still contains the ondemand.s marker, so ClientTransaction initializes correctly and search works again. Fixes public-clis#78. Same underlying issue as public-clis#74/public-clis#69/public-clis#73. Closes the gap left by public-clis#71 (which proposed the same cookie fix but was closed unmerged) — this version also switches the request target from /home's parent (x.com) to x.com/home directly, matching where the authenticated bundle actually lives. Verified locally: `twitter search "seedance prompt" -n 3` returns real results post-patch, 404s pre-patch, using two different accounts (one brand-new, one 2+ years old) to rule out account-age throttling as the cause.
George5402
approved these changes
Aug 1, 2026
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.
Summary
Fixes #78 (same root cause as #74/#69/#73):
twitter searchreturns HTTP 404because
ClientTransactioninit silently fails and falls back to a stalehardcoded
SearchTimelinequeryId.Root cause
_ensure_client_transaction()fetcheshttps://x.comwith a fresh,unauthenticated
curl_cffisession (no cookies at all —_gen_ct_headers()only sets generic browser headers). Since the x.com homepage redesign, the
logged-out response no longer contains the
,<id>:"ondemand.s"webpack chunkmarker that
get_ondemand_file_url()searches for, so parsing fails with'NoneType' object has no attribute 'group'. The exception is swallowed bythe broad
exceptin_ensure_client_transaction, so it only logs a warningand the client silently falls back to the stale hardcoded queryId — which
Twitter now 404s.
I confirmed this by running
get_ondemand_file_url()directly against HTMLfetched two ways: an unauthenticated request to
x.com(fails — noondemand.smarker in the response) vs. an authenticated request tox.com/homewith real session cookies (succeeds).Fix
Attach the client's own
auth_token/ct0cookies to theClientTransactionbootstrap request, and fetch
x.com/home(where the authenticated app shellactually lives) instead of bare
x.com.This overlaps with #71 (closed, unmerged) which proposed the same cookie fix;
this PR also corrects the request target to
/home.Verification
Tested against two different accounts (a brand-new account and one 2+ years
old, to rule out account-age throttling) — both reproduced the 404 pre-patch
and both returned real search results post-patch:
No changes to public API, no new dependencies.