Repository navigation
[fix] Allow websockets 17.x - #17113
Conversation
Co-authored-by: lawilby <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
|
There was a problem hiding this comment.
Summary
This PR raises Streamlit’s published websockets cap from <17 to <18 so Python 3.11+ environments can install Streamlit next to websockets 17.x (#17097). The workspace lock follows the existing pandas pattern: keep 16.1.x on Python 3.10 and force 17.1 on 3.11+ so CI actually exercises the new major. Min-version CI stays on websockets==12.0.0.
The old <17 bound was the routine next-major policy cap from #15948, not a known incompatibility. Streamlit does not import websockets in production; uvicorn’s websockets-sansio protocol (uvicorn >= 0.44) does.
All four expected reviews completed. Three approved; one requested changes over a mixed uvicorn/websockets pairing. Verification finds that pairing real but not merge-blocking (see Backwards Compatibility).
Product Alignment
This is a packaging/installability change, not a new public API, config option, CLI surface, or UI. specs/AGENTS.md lists DevOps/dependency work and small non-controversial enhancements as not requiring a spec; none is expected.
The user-visible effect is that Python 3.11+ users can resolve streamlit with websockets 17.x. Python 3.10 still cannot install 17.x because upstream requires-python is >= 3.11; Streamlit correctly leaves that to websockets rather than promising 17.x on 3.10. Closing #17097 is reasonable for Streamlit’s constraint, with a note that the reporter’s 3.10 environment remains blocked by websockets, not Streamlit.
Code Quality
The diff is minimal and matches documented dependency policy and the pandas 3.x split:
lib/pyproject.tomlkeeps a single published range (>=12.0.0,<18) with the upper bound on the next unreleased major (lib/AGENTS.md).- Root
[tool.uv] override-dependenciesforces 17.x on 3.11+ so the lock/CI do not stay on 16.1.1, which still satisfies<18. uv.lockwas regenerated;requires-distfor streamlit is in sync at>=12.0.0,<18. Thepython_full_version >= '3.15'fallback to 16.1.1 matches the pandas lock markers and the workspaceenvironmentscap (python_version < '3.15').scripts/assets/min-constraints-gen.txtneeds no update: it is generated from lower bounds, and the websockets floor is unchanged at12.0.0.
Complexity is proportionate. No extra abstractions.
Performance
No Streamlit runtime or frontend code changes. Delta queueing, WebSocket flushing, and ping settings in starlette_server.py are untouched. Any 17.x internals difference is upstream; the 17.0 notes describe handshake-level changes (HTTP status responses for malformed handshakes, ISO-8859-1 header encoding) plus an optional Trio path Streamlit does not use. Ping/keepalive in the asyncio path is unchanged, so server.websocketPingInterval handling is unaffected. No Streamlit benchmark is warranted.
Test Coverage
No new tests, which is appropriate for a constraint-only change. Existing coverage actually exercises the new major:
lib/tests/streamlit/fips_test.pystarts a real Streamlit server and opens a realwebsockets.sync.clientconnection to/_stcore/stream. On 3.11–3.14 that is now websockets 17.1 on both client and (via uvicorn) server; on 3.10 it stays 16.1.1.- Min-version CI still covers
websockets==12.0.0. - Playwright e2e covers real browser WebSocket sessions.
That combination covers the floor, the previous major, and the new major. There is still no handshake test for non-ASCII proxy headers (the #16030 failure mode); that gap is pre-existing and is not merge-blocking.
Backwards Compatibility
Widening <17 to <18 is additive: every previously allowed version remains allowed. Python 3.10 still resolves to 16.1.x. Existing 12.x–16.x installs keep working.
Reviewers disagreed on one newly permitted combination: websockets 17.x with uvicorn 0.30–0.51. That pairing can abort /_stcore/stream when a proxy injects non-ASCII identity headers (#16030; uvicorn added the ISO-8859-1 round-trip in 0.52.0). It is a real mixed-version caveat, not a reason to block this cap bump:
- Fresh installs and this repo’s lock resolve uvicorn 0.53.0, which includes the fix.
- Raising the published uvicorn floor from
0.30.0to0.52.0would invalidate currently valid 0.30–0.51 environments that never need websockets 17; that is a larger compatibility change than this additive widen and should be a follow-up if product wants it. - PEP 508 cannot express “websockets>=17 requires uvicorn>=0.52” without extras. The same mixed-version shape already existed for
uvicorn 0.30+websockets16.x.
uvicorn < 0.44 still selects "auto" / websockets.legacy, which still ships in 17.x (removal targeted for 2030). That combination is not in CI and is pre-existing in shape.
Security & Risk
No security-sensitive Streamlit code changed. websockets is already a required runtime dependency; this only widens the allowed range. Lockfile hashes pin 17.1, and exclude-newer = "24 hours" still applies.
Security posture of 17.x is not a regression: 16.1 stripped Authorization/Cookie/Proxy-Authorization on cross-origin redirects, and 17.0 returns HTTP 414/431 when a handshake exceeds security limits instead of dropping the connection. Streamlit’s XSRF, cookie signing, and session-to-identity binding sit above the ASGI boundary and are untouched.
The only material regression risk is the mixed uvicorn < 0.52 + websockets 17.x path behind non-ASCII proxy headers, discussed above. Default and CI stacks are on the safe pairing.
External test recommendation
- Recommend external_test: Yes (indirect; no new marked tests needed on this PR)
- Triggered categories: 3. Websocket handshake and session transport (indirect)
- Evidence:
lib/pyproject.toml: raising the cap to<18changes the library that implements the WebSocket opening handshake and ping/pong keepalive beneath uvicorn’swebsockets-sansioprotocol. websockets 17.0 uses ISO-8859-1 header encoding and replies with HTTP 405/414/431/505 on malformed handshakes.pyproject.toml/uv.lock: Python 3.11+ environments now resolve to websockets 17.1, so hosted deployments on those versions get the new major.- No Streamlit source under
lib/streamlit/web/server/changed, so this is an indirect hit only; categories 1, 2, and 4–11 are not hit.
- Suggested external_test focus areas:
- WebSocket upgrade to
/_stcore/streamthrough a reverse proxy / hosted ingress on Python 3.11+, including a non-ASCII display-name header (e.g. Authelia/AuthentikRemote-Name/X-Authentik-Name). - App load does not stick on “Please wait…”; session reconnect still works.
server.trustedUserHeaders/st.context.headersstill expose those forwarded values.
- WebSocket upgrade to
- Confidence: Medium-High
- Assumptions and gaps: Existing
@pytest.mark.external_testcoverage ine2e_playwright/mega_tester_app_test.pyalready drives a hosted session over the WebSocket, so running the external suite once on this branch is sufficient. One review treated this as a no-hit because no Streamlit server source changed; the any-hit policy still applies because the transport library behind the handshake changed. Assumes the external image has uvicorn >= 0.52 (the safe pairing). Theuvicorn < 0.52+ websockets 17.x combination is not in CI.
Accessibility
Not applicable. No frontend, markup, styling, or interaction changes.
Readability
PR title — [fix] Allow websockets 17.x is specific, matches change:bugfix, and stands alone. Optional: [fix] Allow websockets 17.x on Python 3.11+ would surface that #17097 was filed on 3.10; the body already states that clearly.
PR description — Leads with the change, explains the old policy cap, documents the Python 3.10 consequence up front, and gives a concrete testing plan. Optional wording: replace “unused next-major policy cap” with “routine next-major policy cap.” Optional addition after the 3.10 note: uvicorn 0.52.0+ is the pairing that keeps the #16030 non-ASCII proxy-header path working with websockets 17.
lib/pyproject.toml (comment above the constraint) — “Websockets 17.x requires Python >= 3.11.” matches the pandas comment at line 69. Optional clearer form: “Required for uvicorn WebSocket support. 17.x needs Python >= 3.11; 3.10 stays on 16.x.” Consistency with pandas is a valid reason to leave it.
pyproject.toml override comments — The generalized version-split comment correctly attributes the Python 3.11 floor to both packages. No rewrite requested.
No naming or docstring issues; no Python source changed.
Recommendations
- Optional follow-up: raise the published uvicorn floor to
>=0.52.0(and min-version coverage) if product wants to forbid websockets 17 with uvicorn 0.30–0.51. Do not block this cap bump on that larger compatibility change. - When closing #17097, note that Python 3.10 users still cannot install
websockets>=17.1because 17.x requires Python >= 3.11. - Optional: add a handshake regression that sends a non-ASCII proxy header to
/_stcore/streamso #16030 cannot return silently on a future websockets major. - No new unit tests, no new
@pytest.mark.external_testcases, and no spec are needed for this change.
Verdict
APPROVED: A correct, minimal dependency-range widening that follows the published-range policy and the pandas Python-version split, with CI locked to websockets 17.1 on 3.11+. The uvicorn < 0.52 pairing is a real mixed-version caveat for a follow-up, not a merge blocker.
This is an automated AI review by cursor-grok-4.6-xhigh. Please verify the feedback and use your judgment.
This review also includes 2 inline comment(s) on specific code lines.
There was a problem hiding this comment.
Auto-approved by AI final review (workflow run).
|
The AI QA testing job failed to complete. Please check the workflow run for details. You can retry by adding the 'ai-qa-test' label again or manually triggering the workflow. |
|
Verified that external testing will run for this based on the nightly. |
QA Report: Allow websockets 17.xSummary
Overall statusPASS Streamlit runs correctly on websockets 17.x. App load, widget reruns, session state, fragments, file upload, media, forms, health, and client disconnect/reconnect all worked. Debug server started cleanly. No user-facing regressions found. Test resultsPassed tests
Failed testsNone. Blocked testsNone. Issues foundNone. Early Playwright failures on F4/E1/F9 were test-harness locator mistakes ( Frontend logs contain expected Recommendations
Notes
This is an automated QA report by |
## Describe your changes Logs a startup warning when `websockets` 17+ is paired with `uvicorn` < 0.52.0 . Follow-up to allowing websockets 17.x (#17113). That mix is a legal install, but uvicorn can abort the `/_stcore/stream` handshake when a reverse proxy forwards non-ASCII identity headers (#16030). uvicorn fixed the round-trip in 0.52.0 ([Kludex/uvicorn#3036](Kludex/uvicorn#3036)). The warning can also fire for operators who will never see a non-ASCII proxy header. ## GitHub Issue Link (if applicable) #16030 ## Testing Plan - [x] Unit Tests (JS and/or Python) - [ ] E2E Tests - [ ] Any manual testing needed? --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license. Made with [Cursor](https://cursor.com) --------- Co-authored-by: lawilby <[email protected]>
Describe your changes
Raises the published
websocketscap from<17to<18so Streamlit can install alongside websockets 17.x.The
<17bound was the unused next-major policy cap from #15948, not a known incompatibility. Websockets 17 dropped Python 3.10, so 3.10 installs stay on 16.1.x (same pattern as pandas 3). The workspace lock pins 17.x on Python 3.11+ so CI actually exercises the new major.Python 3.10 +
websockets>=17remains impossible because 17.x itself requires Python >= 3.11.GitHub Issue Link (if applicable)
Testing Plan
websockets==12.0.0. Python 3.10 CI stays on 16.1.x; 3.11+ CI uses 17.1.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Made with Cursor