From 97e0a0645235467321f29763e8155d620456aa4a Mon Sep 17 00:00:00 2001 From: Varun JP Date: Tue, 31 Mar 2026 05:09:01 +0530 Subject: [PATCH] Validate image_ids to prevent empty or invalid inputs --- backend/app/schemas/album.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/app/schemas/album.py b/backend/app/schemas/album.py index cae98e650..36f5689cd 100644 --- a/backend/app/schemas/album.py +++ b/backend/app/schemas/album.py @@ -49,6 +49,19 @@ class GetAlbumImagesRequest(BaseModel): class ImageIdsRequest(BaseModel): image_ids: List[str] + @field_validator("image_ids") + def validate_image_ids(cls, value: List[str]) -> List[str]: + if not value: + raise ValueError("image_ids cannot be empty") + + cleaned = [] + for img_id in value: + if not img_id or not img_id.strip(): + raise ValueError("image_ids must not contain empty values") + cleaned.append(img_id.strip()) + + return cleaned + # ############################## # Response Handler