You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Search returns HTTP 404: x_client_transaction cannot parse new x-web homepage (no ondemand.s bundle) #88
twitter search fails with HTTP 404 since X finished rolling out its new x-web frontend. The x-client-transaction-id header can no longer be generated, which makes graphql endpoints that require it (SearchTimeline) return 404. Read endpoints that don't require the header still work fine.
Environment
twitter-cli 0.8.5 (pipx, Python 3.14.7, macOS)
xclienttransaction 1.0.3 (latest on PyPI)
Auth via explicit TWITTER_AUTH_TOKEN / TWITTER_CT0 env vars (exported from Cookie-Editor, not browser fallback)
-HTTPS proxy in use, but geo is not a factor: authenticated reads work through the same route
Repro
$ twitter search "london" -n 2
WARNING twitter_cli.client: Failed to init ClientTransaction: 'NoneType' object has no attribute 'group'
ok: false
error:
code: not_found
message: 'Twitter API error (HTTP 404): Twitter API error 404: '
Upstream port of xclienttransaction to the x-web architecture; once released, a dependency bump here should restore search. Until then twitter-cli could consider surfacing a clearer error for search (the 404 currently looks like a bad query rather than a missing anti-automation header).
Hi — I'm the author of a Rust port of this tool, twr — same note as on #78/#73 (same root cause family): the new x-web frontend concern from this issue is exactly why twr's resolver treats query IDs as a volatile contract (baseline → cache → rotation → live rescrape, validate-before-use, fail as classified contract-drift) rather than a TTL-cached value. Live-verified today: SearchTimeline works against current x.com including the gated Latest path that requires a fresh transaction id per request. Details in my #78 comment.
Independent repro + a narrower diagnosis than the issue title suggests.
Environment
twitter-cli 0.8.5 (pipx, Python 3.14.6, Windows 11)
XClientTransaction 1.0.3 (latest on PyPI)
Auth via explicit TWITTER_AUTH_TOKEN / TWITTER_CT0 (Cookie-Editor export, no browser fallback)
Repro is unchanged — twitter search 404s while status / feed / user-posts / tweet all work, with the Failed to init ClientTransaction: 'NoneType' object has no attribute 'group' warning.
Narrower root cause
The claim that X removed ondemand.s from the homepage is not quite right. Only the logged-out root URL lost it. I probed each URL with a fresh curl_cffi session per request (a shared session carries cookies across probes and gives misleading results), then ran get_ondemand_file_url() on the response:
URL fetched
auth
ondemand.s in HTML
get_ondemand_file_url()
https://x.com
anonymous
❌ no
AttributeError
https://x.com
+ cookies
✅ yes
OK
https://x.com/home
anonymous
✅ yes
OK
https://x.com/home
+ cookies
✅ yes
OK
https://x.com/search?q=AI&f=live
anonymous
✅ yes
OK
https://x.com/search?q=AI&f=live
+ cookies
✅ yes
OK
So it is not the x-web frontend as a whole — it is specifically the anonymous https://x.com landing page, which now returns a ~32 KB stub with no ondemand.s marker. Every other shell (including /home fetched anonymously) still carries it and parses fine.
Why this matters for the fix
It means the smallest correct change is to stop bootstrapping from the anonymous root URL — no cookies are required:
I verified this end to end: with the init fetched from /home, twitter search returns results again, and search --from <user>, -t latest, and --lang all work. Sending cookies (as several of the open PRs do) also works, but is a larger change than the bug needs and introduces a second credential-carrying request.
Note on the pile-up: there are already 7 open PRs for this (#74, #79, #84, #86, #89, #90, #91). The table above is offered so a maintainer can pick the minimal one (#84's fallback is directionally right but keys off "homepage lacks ondemand.s", whereas the real condition is "the root anonymous page lacks it") rather than merging all seven. Happy to test whichever is chosen.
+1 — independently reproduced on Windows 11 with twitter-cli 0.8.5 (PyPI, latest as of today).
Setup: cookie auth via TWITTER_AUTH_TOKEN / TWITTER_CT0 env vars (Cookie-Editor export), HTTPS traffic through a local HTTP proxy (Clash, 127.0.0.1:7897).
Works fine:
twitter whoami → returns the authenticated profile
twitter user <handle> → profiles with follower counts
twitter user-posts <handle> → timelines incl. media URLs
twitter tweet <id> → tweet + replies
Broken:
twitter search <any query> → every query fails with:
WARNING twitter_cli.client: Failed to init ClientTransaction: 'NoneType' object has no attribute 'group'
Twitter API error (HTTP 0/404): Twitter API error 404:
The ClientTransaction init warning also prints on every command, but authenticated endpoints still work without it, so only search (and possibly other guest-transaction flows) is affected.
Note: this machine is behind GFW-style networking; the proxy makes api.x.com reachable (all working commands prove that), so this does not look network-specific — consistent with #88's hypothesis that the homepage HTML no longer contains the bundle the regex expects (ondemand.s).
Happy to test a candidate patch (pip install from a branch) if that helps.
Adding a data point on the blast radius of this failure, because it is not only search that breaks.
We ran 0.8.5 in a daily posting loop. The Failed to init ClientTransaction warning was printed on every command, reads kept working fine, so nothing looked wrong — but every write was going out without x-client-transaction-id. Writes came back as 344 "You have reached your daily limit" on accounts that had not posted that day, and the accounts whose writes did land were suspended a day or two later (64 Your account is suspended... on the next attempt). We lost accounts to this before we understood what was happening.
That is the part worth fixing no matter which bootstrap fix lands here: when the header cannot be produced, the client currently degrades silently into a bot-shaped client. It should fail closed instead.
I opened #101 for exactly that — it refuses POST when no transaction id could be generated (GET unaffected, since those endpoints do not need it), logs the init failure explicitly, and keeps TWITTER_ALLOW_UNSIGNED=1 as an opt-in escape hatch. It is deliberately independent of the bootstrap PRs (#98, #99, #89, ...), so it can land before or after any of them and turns a future regression into a loud error instead of a suspension.
For completeness, the two root causes we measured on 0.8.5:
anonymous GET https://x.com → ~45 KB page, no ondemand.s at all; the same request with session cookies → ~313 KB and the parser works. That is the "cookie fix" mentioned above.
ON_DEMAND_HASH_PATTERN is defined with escaped quotes inside a raw string (r',{}:\"([0-9a-f]+)\"'), so it never matches even against correct HTML — it needs real quotes. Fixing only the fetch is not enough.
Sorry for the interruption. It seems this repo might be paused/stale. I'm developing twitter_cli as a replacement — feel free to try it if you need an alternative: https://github.com/quangdang46/twitter_cli
Activity
qdang46 commentedon Sep 16, 2026
Hi — I'm the author of a Rust port of this tool, twr — same note as on #78/#73 (same root cause family): the new x-web frontend concern from this issue is exactly why twr's resolver treats query IDs as a volatile contract (baseline → cache → rotation → live rescrape, validate-before-use, fail as classified contract-drift) rather than a TTL-cached value. Live-verified today: SearchTimeline works against current x.com including the gated Latest path that requires a fresh transaction id per request. Details in my #78 comment.
shane1794 commentedon Sep 23, 2026
Independent repro + a narrower diagnosis than the issue title suggests.
Environment
TWITTER_AUTH_TOKEN/TWITTER_CT0(Cookie-Editor export, no browser fallback)Repro is unchanged —
twitter search404s whilestatus/feed/user-posts/tweetall work, with theFailed to init ClientTransaction: 'NoneType' object has no attribute 'group'warning.Narrower root cause
The claim that X removed
ondemand.sfrom the homepage is not quite right. Only the logged-out root URL lost it. I probed each URL with a freshcurl_cffisession per request (a shared session carries cookies across probes and gives misleading results), then ranget_ondemand_file_url()on the response:ondemand.sin HTMLget_ondemand_file_url()https://x.comAttributeErrorhttps://x.comhttps://x.com/homehttps://x.com/homehttps://x.com/search?q=AI&f=livehttps://x.com/search?q=AI&f=liveSo it is not the x-web frontend as a whole — it is specifically the anonymous
https://x.comlanding page, which now returns a ~32 KB stub with noondemand.smarker. Every other shell (including/homefetched anonymously) still carries it and parses fine.Why this matters for the fix
It means the smallest correct change is to stop bootstrapping from the anonymous root URL — no cookies are required:
I verified this end to end: with the init fetched from
/home,twitter searchreturns results again, andsearch --from <user>,-t latest, and--langall work. Sending cookies (as several of the open PRs do) also works, but is a larger change than the bug needs and introduces a second credential-carrying request.Note on the pile-up: there are already 7 open PRs for this (#74, #79, #84, #86, #89, #90, #91). The table above is offered so a maintainer can pick the minimal one (#84's fallback is directionally right but keys off "homepage lacks ondemand.s", whereas the real condition is "the root anonymous page lacks it") rather than merging all seven. Happy to test whichever is chosen.
34787234-svg commentedon Oct 9, 2026
+1 — independently reproduced on Windows 11 with twitter-cli 0.8.5 (PyPI, latest as of today).
Setup: cookie auth via
TWITTER_AUTH_TOKEN/TWITTER_CT0env vars (Cookie-Editor export), HTTPS traffic through a local HTTP proxy (Clash, 127.0.0.1:7897).Works fine:
twitter whoami→ returns the authenticated profiletwitter user <handle>→ profiles with follower countstwitter user-posts <handle>→ timelines incl. media URLstwitter tweet <id>→ tweet + repliesBroken:
twitter search <any query>→ every query fails with:WARNING twitter_cli.client: Failed to init ClientTransaction: 'NoneType' object has no attribute 'group'Twitter API error (HTTP 0/404): Twitter API error 404:Note: this machine is behind GFW-style networking; the proxy makes api.x.com reachable (all working commands prove that), so this does not look network-specific — consistent with #88's hypothesis that the homepage HTML no longer contains the bundle the regex expects (
ondemand.s).Happy to test a candidate patch (pip install from a branch) if that helps.
jmargieh commentedon Oct 18, 2026
Fixed here: #98
oxkage commentedon Oct 29, 2026
Adding a data point on the blast radius of this failure, because it is not only
searchthat breaks.We ran 0.8.5 in a daily posting loop. The
Failed to init ClientTransactionwarning was printed on every command, reads kept working fine, so nothing looked wrong — but every write was going out withoutx-client-transaction-id. Writes came back as344 "You have reached your daily limit"on accounts that had not posted that day, and the accounts whose writes did land were suspended a day or two later (64 Your account is suspended...on the next attempt). We lost accounts to this before we understood what was happening.That is the part worth fixing no matter which bootstrap fix lands here: when the header cannot be produced, the client currently degrades silently into a bot-shaped client. It should fail closed instead.
I opened #101 for exactly that — it refuses
POSTwhen no transaction id could be generated (GETunaffected, since those endpoints do not need it), logs the init failure explicitly, and keepsTWITTER_ALLOW_UNSIGNED=1as an opt-in escape hatch. It is deliberately independent of the bootstrap PRs (#98, #99, #89, ...), so it can land before or after any of them and turns a future regression into a loud error instead of a suspension.For completeness, the two root causes we measured on 0.8.5:
GET https://x.com→ ~45 KB page, noondemand.sat all; the same request with session cookies → ~313 KB and the parser works. That is the "cookie fix" mentioned above.ON_DEMAND_HASH_PATTERNis defined with escaped quotes inside a raw string (r',{}:\"([0-9a-f]+)\"'), so it never matches even against correct HTML — it needs real quotes. Fixing only the fetch is not enough.qdang46 commentedon Oct 30, 2026
Sorry for the interruption. It seems this repo might be paused/stale. I'm developing twitter_cli as a replacement — feel free to try it if you need an alternative: https://github.com/quangdang46/twitter_cli