Repository navigation
Conversation
Several browser cookie-path tests only passed on POSIX hosts:
* They redirected `HOME` but Windows `ntpath.expanduser` reads
`USERPROFILE`, so the fake profile tree was never found.
* They branch on `sys.platform` to build the fixture, but tests that pin
`sys.platform` to exercise POSIX branches cannot use it to decide where
to build the tree; and `platform.system()` derives from the patched
`sys.platform` so it is unreliable too.
* Two assertions hard-coded POSIX separators ('.config/x/Default/Cookies').
Add a `_patch_home` helper (HOME + USERPROFILE, keyed off `os.name`)
and pin the POSIX layout explicitly where a test is asserting POSIX
behaviour. Compare paths with os.path.join instead of literal separators.
No production code changes; this makes the existing suite green on Windows
as well as Linux/macOS.
The ClientTransaction cache stores the full x.com/home HTML, which embeds the session's live auth_token/ct0. It was written with a plain open(), so it inherited the process umask - typically 0644, i.e. readable by every other local user on the host. The index cache (~/.twitter-cli/last_results.json) holds tweet text the user read and had the same problem. Create both through a shared helper that passes 0o600 to os.open() on create (so the file is never briefly world-readable) and fchmods an existing file to narrow permissions left by an older build. Cache directories are tightened to 0700. The helper is best-effort by design: permission changes must never fail the command that triggered a cache write, and on Windows chmod only toggles the read-only bit. Tests assert 0600/0700 on POSIX and are skipped elsewhere, and a negative control confirms they fail against the previous implementation.
Two things made PR status unreadable rather than wrong: * No job timeout, so a stalled install/test run inherited GitHub's 30-day ceiling (runs sat at 'failure 720h' and read as code failures). * First-time contributors hit 'action_required', where the workflow never starts and no checks are reported at all. Set a 20-minute job cap with per-step timeouts, enable uv caching, drop persisted credentials from checkout, add least-privilege permissions and pull-request concurrency cancellation, and document the approval setting maintainers can change. Also fixed the matrix to fail-fast: false so one Python version failing does not hide the others on this 3-version matrix.
mypy 1.14 (the version this project pins) reports the direct os.fchmod call as an unused ignore, while newer mypy needs the ignore because fchmod is missing from some typeshed variants. Resolve it through getattr instead, so the code type-checks cleanly on both.
Actions targeting Node 20 (checkout@v4, setup-python@v5, setup-uv@v6) now emit a deprecation warning on every run. Move to the current majors, which run on node24: checkout@v7, setup-python@v7, setup-uv@v10.3.3 (setup-uv publishes no floating v10 tag, so the release is pinned).
ubuntu-latest migrates to Ubuntu 26 in Oct 2026 and is otherwise a moving target, so a green run today does not prove the next one. Pin ubuntu-24.04.
(cherry picked from commit 4e5966b)
This branch has not been deployed
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.
Seven small, independent fixes on top of
main. They do not depend on any open PR, and each stands alone.While triaging all 29 open PRs I found that the repo cannot currently merge any of the substantive community fixes — every clustered PR fails or never runs (see "CI reality" below). These commits are the gaps none of the open PRs cover, and they make the tree green on Windows as well as Linux.
1.
fix(security): write cache files owner-only_save_ct_cache()writes~/.twitter-cli/transaction_cache.jsonwith a plainopen(), so the file inherits the process umask — typically0644, i.e. readable by every other local user. That JSON embeds the fullx.com/homeHTML, which contains the session's liveauth_token/ct0.~/.twitter-cli/last_results.json(tweet text the user read) had the same problem.Both now go through a shared helper that passes
0o600toos.open()on create, so the file is never briefly world-readable (plainopen()+ laterchmodleaves a window), andfchmods an existing file to narrow permissions left by an older build. Cache directories are tightened to0700.Best-effort by design: permission changes must never fail the command that triggered a cache write, and on Windows
chmodonly toggles the read-only bit.Negative control (real Linux, old code vs new tests):
4 failed, 1 passedof 5 on the previous implementation,5 passednow.2.
test(auth): make browser-path tests platform-independentThis is what makes the suite green on Windows. Four browser-cookie-path tests only passed on POSIX:
HOME, but Windowsntpath.expanduserreadsUSERPROFILE, so the fake profile tree was never found;sys.platformto build the fixture, yet tests that pinsys.platformcannot use it to decide where to build the tree — andplatform.system()derives from the patchedsys.platform, so it is unreliable too (os.nameis fixed at interpreter start and is immune);.config/x/Default/Cookies).No production code changes.
(On Linux both pass in full:
247 passed.)3.
ci: bound job time and document the fork-approval gateTwo things made PR status unreadable rather than merely wrong:
failure 720h(I saw two on fix: restore x-client-transaction-id bootstrap on current X pages #93/fix: restore ClientTransaction bootstrap on current X pages #91, andgh run viewreports "This run likely failed because of a workflow file issue" — a hung run, not a code failure).action_required. First-time contributors never start the workflow, so no checks are reported at all (feat(auth): add Zen browser cookie extraction #95, feat(media): video upload on post, reply, and quote #96, fix: fetch /i/jf/ for ClientTransaction init after x.com Vite migration #98, fix: authenticate transaction bootstrap and update parser dependency #99, fix: refuse GraphQL writes when x-client-transaction-id is unavailable #101 currently sit like this).Adds a 20-minute job cap with per-step timeouts, uv caching,
fail-fast: false(so one Python version failing does not hide the other two),permissions: contents: read,persist-credentials: false, pull-request concurrency cancellation, and a comment documenting the approval setting a maintainer can switch off.4.
ci: move to Node 24 action majorscheckout@v4,setup-python@v5andsetup-uv@v6target Node 20, which now warns on every run. Moved tocheckout@v7/setup-python@v7/setup-uv@v10.3.3(setup-uv publishes no floatingv10tag, so the release is pinned).5.
ci: pin the runner imageubuntu-latestmigrates to Ubuntu 26 in Oct 2026 and is otherwise a moving target; pinned toubuntu-24.04.6.
ci: align Python support validation and badgesAdds Python 3.13 to the test matrix.
requires-pythonis>=3.10, so 3.13 is supported but previously untested; verified green in CI (test (3.13)passes) and locally. Also switches to the dynamic PyPI-python-versions badge. (Restored from a fork-only commit that predates thepublic-clisrename; its 3.8/3.9 entries were dropped because upstream raised the floor to 3.10.)7.
fix(cache): resolve fchmod without a version-specific type ignoremypy 1.14 (the pinned version) reports a direct
os.fchmodcall as an unused ignore, while newer mypy needs the ignore becausefchmodis missing from some typeshed variants. Resolved throughgetattr, so it type-checks on both.CI reality (why the cluster is stuck)
failureat 720h — GitHub's 30-day ceiling on a hung run, not a code failure.action_required— the workflow never starts, so no checks are reported.Verification
Reproduced what CI runs with the project's pinned tooling (
ruff 0.15.4,mypy 1.14.1), on this branch:The 2 skips are the permission-bit tests, which assert
0600/0700and cannot pass on Windows (stat.S_IMODEreturns0o666); they run on Linux.CI on a fork: test (3.10 / 3.11 / 3.12 / 3.13) all pass, zero annotations.