Skip to content

fix(uploads): clean up multipart temporary files - #850

Merged
fatelei merged 1 commit into
mainfrom
fix/849-cleanup-multipart-uploads
Nov 3, 2026
Merged

fatelei merged 1 commit into
mainfrom
fix/849-cleanup-multipart-uploads

Conversation

@41tair

@41tair 41tair commented Nov 3, 2026

Copy link
Copy Markdown
Member

Description

Plugin and bundle uploads that spill to disk leave multipart-* files behind because tracing replaces the request and net/http only cleans the original request.

Defer multipart form cleanup in both upload handlers, covering successful uploads and early error returns. Opened upload files close before cleanup, and cleanup failures are logged with the request context.

Fixes #849

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Regression tests use the actual tracing middleware and upload controllers, lower Gin's memory threshold, and verify that multipart files exist during processing and are removed after the handler returns. They cover size-limit rejection, missing fields or tenant IDs, non-multipart requests, invalid archives, and an accepted bundle.

Validation: go test -count=1 -v -timeout=60s ./internal/server/controllers ./pkg/utils/log and git diff --check.

The multipart cleanup assertions failed before the fix and pass with it.

@fatelei
fatelei merged commit 3d88d05 into main Nov 3, 2026
7 checks passed
@fatelei
fatelei deleted the fix/849-cleanup-multipart-uploads branch November 3, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin uploads over 32MiB leak /tmp/multipart-* files until "no space left on device"

2 participants