Repository navigation
fix(template): upgrade fastapi, starlette and uvicorn together - #358
Conversation
Starlette 0.37.2 (pulled in by fastapi==0.111.0) is affected by CVE-2024-47874. Upgrading Starlette alone breaks kernel interrupts on client disconnect: uvicorn 0.30.1 advertises ASGI spec 2.4 without raising on writes to a closed connection, so Starlette >= 0.42 never cancels the streaming body. uvicorn >= 0.32.1 reports spec 2.3 again, restoring the cancellation path. uvicorn[standard] >= 0.53 needs websockets >= 13, so websockets is bumped as well; the legacy client API the server uses is supported until 2029. Co-Authored-By: [email protected] <[email protected]>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Besides the inline finding, I checked the server for Starlette 1.x removals and found nothing affected. main.py registers startup through FastAPI(lifespan=...) rather than the removed on_event/on_startup hooks, and stream.py only imports starlette.background.BackgroundTask, which Starlette 1.x still provides.
Extended reasoning...
The change only bumps dependency pins in template/server/requirements.txt and adds a patch changeset. The server's Starlette usage (lifespan handler, BackgroundTask) was checked against the 1.x removals and is not affected.
Summary
template/server/requirements.txtpinnedfastapi==0.111.0, which pulls in Starlette 0.37.2 (CVE-2024-47874, fixed in 0.40.0). This bumps the interpreter server to:Why the three have to move together
Kernel interrupts on client disconnect (#213,
ContextWebSocket.execute) rely on Starlette cancelling the streaming body generator (CancelledError/GeneratorExit), which then callsinterrupt()on the Jupyter kernel. Starlette ≥ 0.42 picks the code path by the ASGIspec_versionthe server reports:uvicorn 0.30.1 reports
spec_version: "2.4"but itssend()silentlyreturns on a disconnected client, so with a new Starlette the body generator is never cancelled, the timed-out cell keeps running in the kernel and every later cell in that context queues behind it (this is why the Renovate bumps #207/#302 fail CI). uvicorn 0.32.1 dropped the scope back tospec_version: "2.3"(Kludex/uvicorn#2513), which restores the cancellation path — no server code change needed.Verified locally with a minimal FastAPI streaming app + client that disconnects after 2s:
CancelledError)CancelledError)websockets
messaging.pyuses the legacywebsockets.client.unix_connect/WebSocketClientProtocolAPI. It still works on 17.3 (emits aDeprecationWarning, which the default filters hide outside__main__) and websockets commits to maintaining it until November 2029, so migrating towebsockets.asynciois left for a follow-up.Release
Includes a
patchchangeset for@e2b/code-interpreter-template, so merging triggers the template rebuild/publish viarelease.yml. The PR CI builds a test template and runstests/(incl.test_interrupt.py::test_subsequent_execution_works_after_client_timeout) against it.Supersedes #278 and #302.
Link to Devin session: https://app.devin.ai/sessions/943dbceafe0f4e0a91bc044363751b97
Open in Devin Desktop: https://app.devin.ai/desktop/session/943dbceafe0f4e0a91bc044363751b97?variant=devin
Requested by: @mishushakov