BUG: /sync-folder does not validate the supplied folder_id

Open Beginner friendly
#1,731 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@sathvikn113 is already working on this.

Since Nov 17, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sqlite
Domain
backend, database

Research direction

Read sync_folder() in app/routes/folders.py and the folder lookup helpers in app/database/folders.py, starting with db_get_folder_path_from_id(). Add regression tests for an existing and a nonexistent folder_id; done means a missing folder returns 404 before synchronization makes database changes.

Written by the indexing model from the issue text.

Description

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

While going through the /sync-folder implementation, I noticed that it doesn't check whether the given folder_id actually exists in the database before starting the sync operation.

Where I found the issue

In app/routes/folders.py, the sync_folder() function fetches the child folders using the ID passed in the request:

db_child_folders = db_get_direct_child_folders(request.folder_id)

But there is no check before this to confirm that the folder exists.

I also noticed that db_update_parent_ids_for_subtree() in app/database/folders.py updates parent_folder_id using a regular SQLite connection without enabling foreign-key enforcement. This means an invalid parent ID can be stored in the database.

Expected behaviour

The endpoint should check whether the supplied folder_id exists before proceeding with synchronization. If it doesn't exist, it should return a 404 response without making any database changes.

Possible approach

We could use db_get_folder_path_from_id() in sync_folder() to check whether the folder exists before proceeding.

I would like to work on this and add the necessary regression tests. Please let me know if this behaviour and approach look correct.

Record
  • I agree to follow this project's Code of Conduct
Dominant language
Python
Stars
322
Forks
793
Avg merge
6d 9h
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.