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

Abierto Apto para principiantes
#1,731 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 10 días

@sathvikn113 ya está trabajando en esto.

Desde el 17/11/2026.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, sqlite
Área
backend, database

Línea de trabajo

Lee sync_folder() en app/routes/folders.py y las funciones auxiliares de búsqueda de carpetas en app/database/folders.py, empezando por db_get_folder_path_from_id(). Añade pruebas de regresión para una folder_id existente y otra inexistente; la tarea está terminada cuando una carpeta inexistente devuelve 404 antes de que la sincronización realice cambios en la base de datos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
320
Forks
771
Merge medio
9 d 5 h
PR fusionados (30 d)
15

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AOSSIE-Org/PictoPy

Todos los issues de AOSSIE-Org/PictoPy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.