BUG: Album create/update accept a blank or whitespace-only name

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

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

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

2026年11月17日 から。

評価

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

調査の方向性

backend/app/schemas/album.pyを読み、特に既存のCreateAlbumFromMemoryRequestバリデーターと作成・更新リクエストのスキーマを確認してください。既存のテスト規約に従い、両方のアルバムエンドポイントで空の名前と空白文字のみの名前を対象とするテストを追加してください。両方のリクエストがそのような名前を拒否し、有効な名前は引き続き使えることを完了条件とします。

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

説明

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

Bug Description

The album create and update endpoints accept a blank or whitespace-only name, so an album can be saved with an empty name ("" or " "). The name column has no such guard either, so the blank name is persisted.

Cause

In backend/app/schemas/album.py:

  • CreateAlbumRequest.name is Field(..., min_length=1) (line 25). min_length counts whitespace, so " " (length 3) passes and reaches the database as a blank name.
  • UpdateAlbumRequest.name is a plain str (line 52) with no min_length and no validator at all, so even "" passes.

The project already solved exactly this in the same file: CreateAlbumFromMemoryRequest has a check_not_blank validator (lines 42–48) that strips the value and rejects it if empty, with a comment noting "min_length counts the spaces, so ' ' would otherwise get through." That guard was simply never added to CreateAlbumRequest or UpdateAlbumRequest.

Downstream nothing catches it: the albums.album_name column is TEXT UNIQUE (no NOT NULL, no check), and db_insert_album / db_update_album write the value as-is without stripping.

Steps to reproduce

  1. Create:
    POST /albums/   {"name": "   "}
    
    → 200; an album is created whose name is only spaces.
  2. Update:
    PUT /albums/{id}   {"name": "", "is_locked": false}
    
    → 200; the album's name is now empty.

Expected behavior

Both requests should be rejected with a 422/400 when name is blank or whitespace-only, consistent with CreateAlbumFromMemoryRequest.

Suggested fix

  • Add a check_not_blank field validator (strip, then reject if empty) to CreateAlbumRequest.name and UpdateAlbumRequest.name, mirroring the existing one on CreateAlbumFromMemoryRequest, and store the stripped name.
  • Add tests for the create and update paths.

Notes

Not a duplicate of #1254 (empty/whitespace image_ids, which is already fixed) or #1612 (renaming to an existing name). This is specifically about blank/whitespace album names on create and update.

I'd like to work on this if it's approved.

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 を短くまとめたダイジェスト。