fix(deps): cap Authlib below 1.8 to avoid the httpx2 timeout crash - #916
fix(deps): cap Authlib below 1.8 to avoid the httpx2 timeout crash#916Mighty303 wants to merge 1 commit into
Conversation
Authlib 1.8.0 added a compatibility shim that prefers httpx2 over httpx
whenever httpx2 is importable. Safety builds its clients with an old-httpx
`httpx.Timeout` object (platform/client.py:197, utils/tls_probe.py:166),
which then reaches httpcore2, which expects a number:
sock.settimeout(timeout)
TypeError: 'Timeout' object cannot be interpreted as an integer
Any environment with httpx2 present therefore crashes on every
network-touching command. The user does nothing wrong; safety frequently
shares an environment with a project's own dependencies.
Cap below 1.8. 1.6.12 and 1.7.x carry no shim, so the security floor from
#908 is preserved and the per-invocation AuthlibDeprecationWarning
disappears too.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Artifacts — PR #916 by @Mighty303
Download the wheel file and binaries with gh CLI or from the workflow artifacts. 📦 Install & RunPre-requisites# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create and enter artifacts directory
mkdir artifacts && cd artifactsQuick Test with Python Packagebash -c 'set -euo pipefail; echo; echo "WARNING: You are about to download and execute CI artifacts from PR #916 by @Mighty303. Do NOT proceed unless you have reviewed the PR diff and trust the source."; echo; read -rp "Type I understand to continue: " C; [ "$C" = "I understand" ] || { echo "Aborted."; exit 1; }; gh run download 33907438857 -n dist -R pyupio/safety; uvx safety-*-py3-none-any.whl --version'Run other Safety commands as followsuvx safety-*-py3-none-any.whl auth status
uvx safety-*-py3-none-any.whl auth login
uvx safety-*-py3-none-any.whl scan
|
|
Extra detail supporting the cap, from checking the sibling repo. The existing For contrast, That difference is worth stating explicitly, because a lockfile is not an option here. The version specifier is the only lever that reaches installers, which is what this PR changes. |
Description
Found while checking the resolved dependency set ahead of the next release.
There is no lockfile, so a fresh
pip install safetyresolves Authlib 1.8.0. 1.8.0 added a shim that prefershttpx2overhttpxwhenever httpx2 is importable:Safety builds its clients with an old-httpx
Timeoutobject (safety/platform/client.py:197,safety/utils/tls_probe.py:166). When authlib routes through httpx2, that object reacheshttpcore2, which wants a number:httpx2present anywhere in the environment, plus Authlib ≥ 1.8.0TypeErrorAuthlib>=1.2.0uncapped and is equally exposedFix
Cap below 1.8. This keeps the security floor introduced in #908, and also removes the
AuthlibDeprecationWarningthat 1.8.0 prints to stderr on every invocation.Type of Change
Related Issues
None.
Testing
A dependency cap has no meaningful unit test — the behaviour under test is the resolution itself. Verified by building the wheel and installing it into a clean venv with
httpx2deliberately installed, which is the exact condition that triggers the crash:Same environment on
main(Authlib 1.8.0) raises theTypeErrorabove.Verification:
httpx2:safety auth statussucceeds; onmainit crashesAuthlibDeprecationWarningno longer printed on any invocationtests/integration/test_enroll.py::test_enroll_invalid_key_rejected, which fails identically on pristinemain(env-dependent, unrelated)Checklist
Additional Notes
Follow-up worth doing, deliberately not in this PR. The root cause is that safety passes
httpx.Timeout(...)rather than a plain number. Changing both call sites to pass the float directly makes safety work under httpx and httpx2, which is what would let this cap be lifted:I tested that patch under Authlib 1.8.0 with httpx2 installed and a full
safety auth login+auth statusround-trip succeeded. It is kept out of this PR so the release-unblocking cap stays a one-line review.Worth pairing that follow-up with a CI cell that installs
httpx2, since nothing in the current matrix exercises this combination.