PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

BUG: 500 Internal Server Error on invalid image IDs

Open Prakhar1808 opened this issue 1 month ago • 5 comments

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

Image

Steps to Reproduce

create a test album (password is optional) Image

copy the album_id Image

use that album_id at /albums/{album_id}/images POST endpoint Image

and voila you found Error 500 labelled Undocumented Image

Note

i would like to contribute, assign me

Record

  • [x] I agree to follow this project's Code of Conduct

Prakhar1808 avatar Oct 19 '26 09:10 Prakhar1808

👋 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 :)

github-actions[bot] avatar Oct 19 '26 09:10 github-actions[bot]

⚠️ Potential Duplicate Issue (Semantic Match)

This issue appears semantically similar to the following issues in AOSSIE-Org/PictoPy:

  1. 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%

  2. BUG: fix: return 404 when removing image not in album (#1560, closed) https://github.com/AOSSIE-Org/PictoPy/issues/1560 Similarity: 67.4%

  3. BUG: Proper reporting of duplicate album error. (#112, closed) https://github.com/AOSSIE-Org/PictoPy/issues/112 Similarity: 65.9%

Please review before proceeding.

github-actions[bot] avatar Oct 19 '26 09:10 github-actions[bot]

I'm unable to understand, other than the swagger ui, when exactly would the 500 error occur in the app? Which scenario? @Prakhar1808

rohan-pandeyy avatar Oct 19 '26 15:10 rohan-pandeyy

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

Prakhar1808 avatar Oct 19 '26 17:10 Prakhar1808

OK. Please go ahead with the issue's resolution.

rohan-pandeyy avatar Oct 19 '26 17:10 rohan-pandeyy