Skip to content

fix: close temporary files after oversized clip uploads - #25

Open
Luqueee wants to merge 1 commit into
mainfrom
codex/close-clip-upload-temp
Open

Luqueee wants to merge 1 commit into
mainfrom
codex/close-clip-upload-temp

Conversation

@Luqueee

@Luqueee Luqueee commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #9.

Ensure temporary clip upload files are closed on every handler path, including http.MaxBytesError. The close helper is idempotent and the cleanup defer removes any uncommitted temporary path.

Validation

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • git diff --check

Added a Linux regression test that sends repeated oversized uploads and verifies there are no open or stale mole-clip-put-* files afterward.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 97826ba8-8d69-421c-84fe-aad98571a321

📥 Commits

Reviewing files that changed from the base of the PR and between bd661cf and 543bfbe.

📒 Files selected for processing (2)
  • internal/clip/server.go
  • internal/clip/server_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Improved cleanup of temporary upload files when uploads fail.
    • Ensured file-close errors are recorded during failed uploads.
    • Prevented temporary files and file descriptors from being left behind after oversized requests.
  • Tests

    • Added coverage confirming oversized uploads return HTTP 413 and clean up resources correctly on Linux.

Walkthrough

The upload handler now closes temporary files through an idempotent helper on error paths and removes temporary files during cleanup. Linux tests repeat oversized PUT requests and check for descriptor or temporary-file leaks.

Changes

Temporary upload cleanup

Layer / File(s) Summary
Close temporary uploads and validate cleanup
internal/clip/server.go, internal/clip/server_test.go
handlePut centralizes temporary-file closure, logs close failures after body-copy errors, and preserves HTTP error responses. Linux-only tests verify repeated oversized PUT requests return HTTP 413 without descriptor or temporary-file leaks.

Merge Risk: ⚪ Minimal · up to 543bf

Oversized uploads now close and remove temporary files on error paths while preserving existing error responses and atomic publication behavior. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required Conventional Commit format and clearly describes the temporary-file fix for oversized clip uploads.
Description check ✅ Passed The description directly explains the temporary-file cleanup fix, affected error paths, validation, and regression test.
Linked Issues check ✅ Passed The changes address issue #9 by making temporary-file closing idempotent, covering oversized uploads and handler failure paths, preserving cleanup, and adding repeated-upload regression coverage.
Out of Scope Changes check ✅ Passed All implementation and test changes are directly related to temporary clip upload cleanup and issue #9 acceptance criteria.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/close-clip-upload-temp

Comment @coderabbitai help to get the list of available commands.

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.

Close temporary clip upload files on every server error path

1 participant