Bug: Attachment upload leaks file handles on partial failure #6
Labels
No labels
blocked:gate-research
bug
feature-request
in-progress
needs-triage
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/vikunja-cli#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: Low-Medium
In
vikunjatool/api/client.py(and duplicated invikunja_cli/api/client.py), theupload_task_attachmentsmethod opens files and appends them to a list before entering the try block. If one of theopen()calls raises an exception (e.g., file not found), the previously opened file handles in the list are never closed.If file_paths = ["valid1.pdf", "nonexistent.pdf", "valid2.pdf"], opening nonexistent.pdf raises FileNotFoundError, but valid1.pdf's handle is never closed.
Fix: Use a context manager (
open()inside the try block) or usewithstatements. Open files lazily or one by one, ensuring cleanup on any exception path.Fixed in commit. Closing.