fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501) - #48259
Merged
Merged
Conversation
Contributor
🔎 Lint report:
|
Collaborator
|
Related: #47663 (original by @benbarclay, this is the cherry-pick onto current |
…python-multipart (NS-501) Follow-up to #47663 (streaming multipart upload), fixing two issues that landed with it. 1. Temp file leaked on client disconnect. The streaming upload endpoint's except chain caught only HTTPException / PermissionError / OSError — all Exception subclasses. asyncio.CancelledError, raised when a browser aborts a large upload mid-stream (the exact NS-501 scenario), is a BaseException, so it bypassed every except clause and reached a finally that only closed the file handle and never unlinked the temp file. Every aborted large upload orphaned a partial `.{name}.*.upload` file (up to ~100 MB) in the target directory. Cleanup now lives in finally, keyed on a `renamed` success flag, so the temp file is removed on every non-success exit including BaseException paths. Added test_stream_upload_cleans_temp_on_cancellation, which fails on the pre-fix code (leaks the temp file) and passes with the fix. 2. python-multipart pinned to ==0.0.27 instead of ==0.0.20. The package was already resolved at 0.0.27 transitively (via daytona) before #47663; the explicit ==0.0.20 pin in the [web] extra and the tool.dashboard lazy-install set downgraded it. Bumped both to ==0.0.27 and regenerated with `uv lock`, keeping the lockfile coherent. The base dependency stays >=0.0.9,<1.
kshitijk4poor
force-pushed
the
fix/ns501-multipart-upload-salvage
branch
from
June 18, 2026 06:02
edd68fd to
6752da9
Compare
kshitijk4poor
enabled auto-merge
June 18, 2026 06:07
alt-glitch
approved these changes
Jun 19, 2026
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…tipart-upload-salvage fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501)
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…tipart-upload-salvage fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501)
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…tipart-upload-salvage fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…tipart-upload-salvage fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501)
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…tipart-upload-salvage fix(dashboard): clean up upload temp file on client disconnect + pin python-multipart (NS-501)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #47663 (NS-501)
#47663 (streaming multipart upload for the dashboard file manager) merged as
c66163453. This is a tight follow-up fixing two issues that landed with it. No feature/frontend changes — only the two fixes below + a regression test.mainupload_managed_file_stream'sexceptchain catches onlyHTTPException/PermissionError/OSError— allExceptionsubclasses.asyncio.CancelledError(raised when a browser aborts a large upload mid-stream — the exact NS-501 scenario) is aBaseException, so it bypasses everyexceptand reaches afinallythat only closes the file handle and never unlinks the temp file. Every aborted large upload orphans a partial.{name}.*.uploadfile (up to ~100 MB) in the target directory.finally, keyed on arenamedsuccess flag, so the temp file is removed on every non-success exit includingBaseException. (os.replaceclearstmp_pathon success, so we only unlink when the rename didn't happen.)python-multipartneedlessly downgraded. The package was already resolved at 0.0.27 transitively (viadaytona) before #47663; the explicit==0.0.20pin in the[web]extra +tool.dashboardlazy-install set downgraded it.==0.0.27and regenerated viauv lock(Updated python-multipart v0.0.20 -> v0.0.27). Base dep stays>=0.0.9,<1.uv lock --checkpasses. (0.0.20 was past CVE-2024-53981 too, so this is lockfile hygiene, not a security fix.)Validation
test_stream_upload_cleans_temp_on_cancellation— mutation-tested against currentmain: it fails on the merged code (leaks.aborted.bin.*.upload) and passes with the fix. It invokes the endpoint coroutine directly so theBaseExceptionpropagates instead of being swallowed by the test client.ruff checkclean.uv lock --checkpasses;python-multipartresolves to 0.0.27 (no downgrade).Diff is scoped to 5 files (+67/-9):
hermes_cli/web_server.py,pyproject.toml,tools/lazy_deps.py,uv.lock,tests/hermes_cli/test_web_server_files.py.Reviewer notes
Touches
pyproject.toml/tools/lazy_deps.py/hermes_cli/web_server.py(a dependency pin + dashboard API surface), so this is out of the pure-Docker lane → flagging for Teknium review.Follow-up to #47663. Surfaced during review of #47663.