fix(webui): migrate Starlette TestClient to httpx2 (Closes #682) #884
Merged
sysadmin
merged 2 commits from 2026-07-24 18:11:02 -05:00
fix/issue-682-starlette-httpx2 into master
Labels
Clear labels
allocator
anti-stomp
architecture
bug
chore
codex
concurrency
contamination
control-plane
dashboard
database
design
documentation
enhancement
gitea
glitchtip
important
incident
incident-bridge
integration
jenkins
labels
leases
mcp
mcp-health
mcp-menu
multi-project
mutating
nice-to-have
observability
portability
preflight
protected-branch
queue
read-only
reconnect
recovery
refactor
release
reliability
resumable-review
reviewer
roadmap
safety
security
self-hosted
sentry
stale-runtime
status:blocked
status:in-progress
status:pr-open
status:ready
terminal-lock
testing
tracker
type:bug
type:feature
type:feature
type:guardrail
visibility
workflow
workflow-hardening
workflow-hardening
Controller-owned work allocator
Prevent concurrent LLM session stomping
Architecture / structural design
OpenAI Codex client / workflow session surface
Concurrent session safety
Workflow or session contamination incident
MCP control-plane coordination and allocation authority
MCP operational dashboard/queue view
Internal coordination storage (SQLite/Postgres)
Design / investigation, no implementation
Docs / runbooks
New feature or improvement
Gitea MCP workflow
GlitchTip integration
Operational or process incident requiring durable audit trail
Sentry-to-Gitea incident bridging
Integration testing
Jenkins integration
Label taxonomy management
Lease adopt/release/expire lifecycle
MCP server / tooling
MCP namespace and runtime health
MCP menu surface
Work spanning multiple monitoring projects or Gitea repos
Mutating action; requires gating
Observability, metrics, traces, error reporting
Cross-platform / portability
Shared preflight gates before mutation
Protected branch / stable-branch policy concern
Work queue visibility and allocation
Read-only, no mutation
MCP client reconnect/reload recovery path
Recovery paths for stale/foreign leases
Code refactor / restructure
Release / versioning
Reliability / failure handling
Persist and resume prepared review verdicts across sessions
Reviewer workflow tooling
Roadmap / umbrella issue
Safety rails and fail-closed mutation guards
Security / trust boundary
Self-hosted infrastructure integration
Sentry error monitoring integration
Stale backend daemon / runtime-vs-master parity failures
Issue is blocked
Issue is being worked on
Issue has an open pull request
Issue is ready for work
Terminal review lock (#332) path
Tests / test coverage
Issue tracker hygiene / meta
Bug or defect
Feature or enhancement
Feature or enhancement
Safety gate or guardrail
Workflow state visibility for LLMs/operators
Cross-tool workflow
LLM workflow coordination hardening
LLM workflow coordination hardening
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#884
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Starlette 1.3.x emits
StarletteDeprecationWarningwhenstarlette.testclient.TestClientfalls back to plainhttpx. Install and pinhttpx2so Web UI tests use the supported client path without warning filters.Dependency versions
Changes
httpx2==2.9.1inrequirements.txtwith a short note that runtime MCP still useshttpx.tests/webui_testclient.pyas the single intentional Web UITestClientimport surface.tests/test_webui_*.pymodules at that helper.tests/test_issue_682_starlette_httpx2.pyproving import no longer warns and the helper client works.Test plan
pytest tests/test_issue_682_starlette_httpx2.py tests/test_webui_audit.py -q→ 12 passedscripts/test-webui -q→ 460 tests OKCloses #682
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #884
issue: #682
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 85239-4f4db84a6d07
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr884
phase: claimed
candidate_head:
5deb66c7f6target_branch: master
target_branch_sha:
870843f999last_activity: 2026-07-24T22:14:03Z
expires_at: 2026-07-24T22:24:03Z
blocker: none
Canonical PR State
STATE:
changes-requested
WHO_IS_NEXT:
author
NEXT_ACTION:
Package-qualify the
webui_testclientimport in the 18 rewrittentests/test_webui_*.pymodules and intests/test_issue_682_starlette_httpx2.py, drop the now-unneededsys.path.insertin the latter, then re-request review at the new head.NEXT_PROMPT:
WHAT_HAPPENED:
Reviewed at head
5deb66c7f6against base master870843f999in worktree branches/review-pr884. The dependency migration is correct and well-evidenced. The new shared import surface is not:tests/__init__.pyexists, sotests/is a package and pytest /unittest discoverplace the repo root onsys.path, nevertests/. The helper is therefore only importable astests.webui_testclient, but all 18 rewritten modules use the bare top-level namewebui_testclient. Each of those modules now fails to import when run on its own.The PR's three green signals all miss this.
tests/test_issue_682_starlette_httpx2.pydoessys.path.insert(0, ...parent)at import time, so whichever module imports first leakstests/onto the path for the rest of the process:Same two files, reversed.
scripts/test-webuipasses for an unrelated reason (unittest discover -s testsinsertstests/itself, and itstest_webui_*.pypattern never loads the #682 module). Fullpytest tests/passes only becausetest_issue_682...sorts alphabetically ahead oftest_webui_*.Observed at this head:
Fix verified in a scratch worktree (reverted, nothing pushed) — after package-qualifying the import:
pytest tests/test_webui_audit.py9 passed; reversed-order pair 12 passed;scripts/test-webui460 OK;unittest tests.test_webui_audit9 OK.Also LOW / non-blocking:
test_starlette_testclient_import_does_not_warndeletesstarlette.testclientfromsys.modulesand re-imports without restoring, leaving a different class object insys.moduleswhile earlier importers still hold the original. Harmless today, but it is unrestored global state in a suite whoseconftest.pyotherwise resets aggressively. Considerunittest.mock.patch.dict(sys.modules).WHY:
The stated goal is a single canonical Web UI TestClient import surface. As written that surface is unreachable under the project's own package layout for every consumer except one ordering accident, so the change makes 18 previously self-runnable test modules un-runnable in isolation. The fix is one mechanical rewrite and preserves every property the PR set out to achieve.
ISSUE:
#682
HEAD_SHA:
5deb66c7f6REVIEW_STATUS:
request_changes
MERGE_READY:
no
BLOCKERS:
from webui_testclient import TestClientdoes not resolve under pytest orunittest discoverbecausetests/is a package (tests/__init__.pypresent); all 18 rewrittentests/test_webui_*.pymodules fail to import in isolation. Blocking; fix is to import astests.webui_testclient.VALIDATION:
870843f, 0 commits behind, mergeable, no conflicts.testclient.py:42instructspip install httpx2and:48emits the deprecation this PR removes. Package is github.com/pydantic/httpx2; starlette'sfullextra declareshttpx2>=2.0.0, satisfied by the==2.9.1pin.pip checkreports no broken requirements. Keepinghttpx==0.28.1for MCP/runtime is correct (separate top-level modules).870843f= 23 failed / 5099 passed; head5deb66c= 23 failed / 5102 passed. Failure sets identical (commdiff empty both directions). Zero new failures; +3 are this PR's new tests.test_webui_*modules (architecture_docs, ci_gate, sanctioned_restart, worker_registry) do not use TestClient at all. Only remaining directstarlette.testclientimports are inside the helper and the deliberate deprecation probe.LAST_UPDATED_BY:
sysadmin / prgs-reviewer / 2026-07-24
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #884
issue: #682
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 85239-4f4db84a6d07
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr884
phase: released
candidate_head:
5deb66c7f6target_branch: master
target_branch_sha:
870843f999last_activity: 2026-07-24T22:15:56Z
expires_at: 2026-07-24T22:25:56Z
blocker: manual-release
Re-requested review at updated head
c74b8da.webui_testclientimport asfrom tests.webui_testclient import TestClientacross all 18tests/test_webui_*.pymodules andtests/test_issue_682_starlette_httpx2.py.sys.path.insert(0, ...parent)fortests/intest_issue_682_starlette_httpx2.py.sys.modulescleanup/restoration intest_starlette_testclient_import_does_not_warn.Verified across all four isolation targets:
pytest tests/test_webui_audit.py -q→ 9 passedpytest tests/test_webui_audit.py tests/test_issue_682_starlette_httpx2.py -q→ 12 passedWEBUI_TEST_OFFLINE=1 scripts/test-webui -q→ 460 tests OKpython3 -m unittest tests.test_webui_audit→ 9 passedrepo: Scaled-Tech-Consulting/Gitea-Tools
pr: #884
issue: #682
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 85239-e074658df5a1
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr884
phase: claimed
candidate_head:
c74b8da400target_branch: master
target_branch_sha:
870843f999last_activity: 2026-07-24T22:31:06Z
expires_at: 2026-07-24T22:41:06Z
blocker: none
Canonical PR State
NATIVE_REVIEW_PROOF: native prgs-reviewer MCP review mutation via gitea_submit_pr_review, profile prgs-reviewer, identity sysadmin, session 85239-e074658df5a1, reviewer lease comment 16189, workflow hash 263d0a6cb8a6, head
c74b8da400pinned via gitea_mark_final_review_decision.STATE:
approved
WHO_IS_NEXT:
merger
NEXT_ACTION:
Merge PR #884 at head
c74b8da400. Base is current (0 commits behind master870843f), mergeable, no conflicts, no required checks.NEXT_PROMPT:
WHAT_HAPPENED:
Re-review at head
c74b8da400against base master870843f999, in worktree branches/review-pr884. Both findings from the REQUEST_CHANGES at5deb66c7are fixed in commitc74b8da.Blocking finding (import surface unreachable) — resolved. All 18
tests/test_webui_*.pymodules now usefrom tests.webui_testclient import TestClient, andtests/test_issue_682_starlette_httpx2.pyboth package-qualifies its own import and drops thesys.path.insert(0, str(Path(__file__).resolve().parent))line that was masking the defect by leakingtests/ontosys.pathfor whatever imported after it. The fix is the package-qualified form rather than more path manipulation, which is the right direction:tests/__init__.pyexists, sotests/is a package andconftest.pyalready places the repo root onsys.path.LOW finding (unrestored
sys.modules) — resolved.test_starlette_testclient_import_does_not_warnnow snapshots thestarlette.testcliententries intosaved, deletes them inside atry, and restores viasys.modules.update(saved)in afinally. Global state is no longer left mutated for subsequent tests.Every invocation path that previously failed now passes, including the ones the original test plan did not exercise:
WHY:
The dependency migration was correct from the outset — verified directly against the installed starlette 1.3.1 source rather than the PR narrative. The only blocker was that the new shared import surface could not resolve under the project's own package layout, so 18 previously self-runnable test modules became un-runnable in isolation and the PR's green signals were an artifact of module import ordering. That is now fixed at the root, without warning filters, path hacks, or weakened assertions, and with no change to the production client path.
ISSUE:
#682
HEAD_SHA:
c74b8da400REVIEW_STATUS:
approve
MERGE_READY:
yes
BLOCKERS:
none
VALIDATION:
5deb66c7->c74b8da4during review; every claim here is measured atc74b8da4, not carried over. Base current at870843f, 0 commits behind, mergeable, has_conflicts false, checks not required.testclient.py:42instructspip install httpx2;:48emits the deprecation this PR removes. Package is github.com/pydantic/httpx2; starlette'sfullextra declareshttpx2>=2.0.0, satisfied by the==2.9.1pin.pip checkreports no broken requirements.httpx==0.28.1correctly retained for MCP/runtime (separate top-level module).870843f= 23 failed / 5099 passed / 6 skipped; headc74b8da= 23 failed / 5102 passed / 6 skipped. Failure sets identical (commdiff empty in both directions). Zero new failures; the +3 are this PR's own new tests. The 23 are pre-existing on master and unrelated to this change.test_webui_*modules (architecture_docs, ci_gate, sanctioned_restart, worker_registry) do not use TestClient at all, so coverage is exhaustive.starlette.testclientimports are inside the helper itself and the deliberate deprecation probe.LAST_UPDATED_BY:
sysadmin / prgs-reviewer / 2026-07-24
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #884
issue: #682
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 85239-e074658df5a1
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr884
phase: released
candidate_head:
c74b8da400target_branch: master
target_branch_sha:
870843f999last_activity: 2026-07-24T22:32:43Z
expires_at: 2026-07-24T22:42:43Z
blocker: manual-release
repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #884
issue: #682
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 84870-90dd5a811ae5
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr884
phase: claimed
candidate_head:
c74b8da400target_branch: master
target_branch_sha:
870843f999last_activity: 2026-07-24T23:10:45Z
expires_at: 2026-07-24T23:20:45Z
blocker: none