BUG: 500 Internal Server Error on invalid image IDs
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
Description
When a client requests adding image IDs to an album, and none of those IDs exist in the database, db_add_images_to_album raises ValueError("None of the provided image IDs exist in the database.")
Screenshots
Steps to Reproduce
create a test album (password is optional)
copy the album_id
use that album_id at /albums/{album_id}/images POST endpoint
and voila you found Error 500 labelled Undocumented
Note
i would like to contribute, assign me
Record
- [x] I agree to follow this project's Code of Conduct
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
⚠️ Potential Duplicate Issue (Semantic Match)
This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:
-
BUG: Missing validation for empty or whitespace image_ids in Album requests (#1254, closed) https://github.com/AOSSIE-Org/PictoPy/issues/1254 Similarity: 67.4%
-
BUG: fix: return 404 when removing image not in album (#1560, closed) https://github.com/AOSSIE-Org/PictoPy/issues/1560 Similarity: 67.4%
-
BUG: Proper reporting of duplicate album error. (#112, closed) https://github.com/AOSSIE-Org/PictoPy/issues/112 Similarity: 65.9%
Please review before proceeding.
I'm unable to understand, other than the swagger ui, when exactly would the 500 error occur in the app? Which scenario? @Prakhar1808
I'm unable to understand, other than the swagger ui, when exactly would the 500 error occur in the app? Which scenario? @Prakhar1808
error 500 can occur in the app in stale-state, If the user opens the "Add to Album" modal, and in the meantime an image is deleted (or removed from disk), the modal's state still holds the stale image. Submitting it causes db_add_images_to_album to raise ValueError("None of the provided image IDs exist in the database."), which currently bubbles up as a 500 Internal Server Error
Right now in albums.py, remove_image_from_album already explicitly catches except ValueError and maps it to 404 Not Found (Image Not Found in Album). add_images_to_album is simply missing this mapping, so client/validation errors accidentally return a 500 instead of a 404/400
OK. Please go ahead with the issue's resolution.