chore: migrate tests to starlette 1.x TestClient; lift starlette<1.0 constraint - #40
chore: migrate tests to starlette 1.x TestClient; lift starlette<1.0 constraint#40t41372 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis PR removes the pinned Starlette ChangesStarlette Cap Removal and httpx2 Migration
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Dependency ReviewThe following issues were found:
License Issuesuv.lock
OpenSSF Scorecard
Scanned Files
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@coderabbitai review |
Action performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pyproject.toml`:
- Around line 67-75: The dependency note in pyproject.toml overstates the
verified multipart behavior by claiming the fastapi>=0.118 floor and 0.116 422
regression without a source. Remove that unsupported claim from the surrounding
comment near the httpx2/fastapi dependency entries, or replace it with a
documented, verifiable reference; keep the Starlette 1.x and fastapi>=0.133
explanation intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ddbfcb67-9979-47c3-8799-e547fd8c0177
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
.github/dependabot.ymlCONTRIBUTING.mddocs/compatibility-advisories.mdpyproject.tomltests/test_server.py
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
8ff3a60 to
f5f0687
Compare
…constraint The dev-only `[tool.uv] constraint-dependencies = ["starlette<1.0"]` pin held the lock at Starlette 0.52.1 and blocked five open Dependabot alerts (2 high, 2 medium, 1 low) — all Starlette, all fixed in Starlette >= 1.3.1. The pin existed only because Starlette's `TestClient` moved to the `httpx2` transport (Starlette 1.2.0, "Support httpx2 in the test client", Kludex/starlette#3291) while our FastAPI server tests still drove it through the classic `httpx`-based client. Migrate to the httpx2 transport and drop the constraint: - Dev dependency `httpx>=0.28` -> `httpx2>=2.0`; server-test response annotations `httpx.Response` -> `httpx2.Response` (tests/test_server.py). The TestClient surface is otherwise identical (httpx2 is Pydantic's fork of httpx), so the assertions are unchanged. - Security floors (the load-bearing rationale): all five GHSAs are fixed only on the Starlette 1.x line, with no 0.x backports, so `starlette>=1.3.1` is declared directly in the `[server]` extra as a fail-loud floor — an app pinning a vulnerable 0.x Starlette now gets a resolver error instead of a silently vulnerable server. The `fastapi` floor rises 0.118 -> 0.133 in both the `test` group and `[server]`: 0.133 is the first release to drop FastAPI's own `starlette<1.0.0` cap (0.132 still pins it), i.e. the lowest fastapi that can coexist with the patched line. It subsumes the earlier 0.118 multipart-coercion floor (kept as recorded history; today's lower-bounds lane resolves 0.133 and can no longer re-verify it). - Remove the two now-obsolete `filterwarnings` ignores (the httpx-transport and `app=` shortcut deprecations no longer fire under httpx2; `["error", ...]` proves it — the suite stays green with them gone). - Re-resolve the lock: Starlette 0.52.1 -> 1.3.1, httpx dropped, httpx2 2.5.0, httpcore2 2.5.0 and truststore added (httpx2's trust-store chain replaces certifi), fastapi stays 0.136.3. Docs/config kept consistent: the advisory in docs/compatibility-advisories.md moves to "Resolved" (dated); the stale `starlette<1.0` example references in CONTRIBUTING.md and .github/dependabot.yml are updated. Gates: ruff clean, pyright strict 0 errors, pytest 1722 passed at 100% line+branch coverage (py3.13), and the lower-bounds floor stack (fastapi 0.133.0 + starlette 1.3.1 + httpx2 2.0.0, py3.10) passes the full suite.
f5f0687 to
ffe5ce6
Compare
Pulls the httpx2 migration forward from its 2026-09 revisit date to clear all 5 open Dependabot alerts (2 high / 2 medium / 1 low — all starlette, all fixed in ≥1.3.1).
What blocked the fix
Our own documented dev-only constraint:
[tool.uv] constraint-dependencies = ["starlette<1.0"], because starlette 1.x's TestClient runs on thehttpx2transport while our server tests used the classic httpx one.What the migration actually required
Less than feared: the TestClient API surface is identical under httpx2 — the real change was
import httpx→import httpx2plus 49httpx.Responsetype annotations intests/test_server.py. Assertions untouched.Changes
httpx>=0.28→httpx2>=2.0; security floors:starlette>=1.3.1declared directly in[server](all 5 GHSAs are fixed only on the 1.x line, no 0.x backports — a vulnerable pin now fails at resolve time instead of installing a silently vulnerable server) and fastapi floor 0.118 → 0.133 in both the test group and the[server]extra (0.133 is the first release to drop FastAPI's ownstarlette<1.0.0cap, i.e. the lowest fastapi that can coexist with the patched line; it subsumes the historically-verified 0.118 multipart floor). Removed the constraint + the two obsoletefilterwarningsignores (suite runs warning-clean without them, underfilterwarnings=error).Verification
ruff clean · pyright 0 errors (full project) · pytest 1722 passed, 100% line+branch · lower-bounds lane simulated locally (
--resolution lowest-direct, py3.10 → fastapi 0.133.0 + starlette 1.3.1 + httpx2 2.0.0): 1722 passed, 100% ·uv lock --checkpasses.Summary by CodeRabbit
Bug Fixes
Documentation