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

オープン 初心者向け
#1,731 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 10 日以内に返信

@sathvikn113 がすでに取り組んでいます。

2026年11月17日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, sqlite
領域
backend, database

調査の方向性

app/routes/folders.py の sync_folder() と、app/database/folders.py のフォルダー検索ヘルパーを読み、まず db_get_folder_path_from_id() を確認してください。存在する folder_id と存在しない folder_id の回帰テストを追加してください。フォルダーが見つからない場合に、同期によるデータベースの変更が行われる前に 404 が返されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
320
フォーク
771
平均マージ
9日 5時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/PictoPy のほかの issue

AOSSIE-Org/PictoPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。