BUG: Face search leaves temp files in a relative temp_uploads/ folder

Open
#1,682 9 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@karthikeyakakarlapudi2007 is already working on this.

Since Nov 5, 2026.

  • #1698 by @Hari20032005 — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
57/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in backend/app/routes/face_clusters.py around face_tagging() and trace how the uploaded image reaches perform_face_search and how the finally block cleans it up. Check the existing user data directory and test layout before choosing an approach. Add coverage for cleanup after success and when face search raises; done when uploads do not remain in a relative temp_uploads/ folder and the cleanup test passes.

Written by the indexing model from the issue text.

Description

bug
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

BUG: Face search leaves temp files in a relative temp_uploads/ folder

What happened?
When face search is called with a base64 image, face_tagging() in
backend/app/routes/face_clusters.py (around line 357) writes the upload to
a hardcoded relative folder:

temp_dir = "temp_uploads"
os.makedirs(temp_dir, exist_ok=True)

Problems:

  1. The path is relative to the process's working directory, so the folder
    appears wherever the backend was launched (e.g. the repo root or backend/
    in dev) and its location differs between dev and the packaged app.
  2. temp_uploads/ is not in .gitignore, so it can be accidentally committed.
  3. Cleanup happens in a finally block, but if the process is killed
    mid-request (app quit, crash) the uploaded image stays on disk. Nothing
    removes leftovers on the next start. For a privacy-first app, user
    photos lingering in an unmanaged folder is undesirable.

Found by reading the code; not yet reproduced at runtime.

Suggested fix

  • Use Python's tempfile (NamedTemporaryFile / mkstemp) or a subfolder of
    the existing user data dir instead of "temp_uploads".
  • If perform_face_search can accept bytes/an array, skip writing to disk.
  • Add a test covering that the temp file is removed after the request,
    including when face search raises.
Record
  • I agree to follow this project's Code of Conduct
Dominant language
Python
Stars
322
Forks
793
Avg merge
6d 10h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/PictoPy

All issues in AOSSIE-Org/PictoPy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.