BUG: Add images to album: success message shows requested count, not number actually added

Open Beginner friendly
#1,740 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@riyanshbhosale is already working on this.

Since Nov 22, 2026.

  • #1764 by @riyanshbhosale — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Read backend/app/routes/albums.py and backend/app/database/albums.py to trace how many rows the database function inserts and how the route builds its response. Add route and database tests for mixed valid and invalid IDs, IDs already in the album, and repeated IDs; the success message should report the number actually added. Run the relevant tests for these files.

Written by the indexing model from the issue text.

Description

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

I was reading through the album routes and noticed the "Added N images" message uses the length of the request, not what was actually inserted.

Where

backend/app/routes/albums.py (~line 375):

db_add_images_to_album(album_id, body.image_ids)
request_metadata_export(app_state)
return SuccessResponse(
    success=True, msg=f"Added {len(body.image_ids)} images to album"
)

db_add_images_to_album() in backend/app/database/albums.py only inserts IDs that exist in images, uses INSERT OR IGNORE, and returns nothing, so the route can't know how many rows were really added.

What I think happens

  • One existing ID plus one nonexistent ID: one row should be inserted, but the message should say "Added 2 images to album".
  • An ID already in the album is skipped by INSERT OR IGNORE but should still be counted in the message.
  • A repeated ID in one request should be counted twice in the message but inserted once.

I found this by reading the code and the existing tests. The existing 404 test mocks the DB function, so mixed valid/invalid IDs aren't covered.

Possible fix

Return cursor.rowcount from db_add_images_to_album() and use it in the route message, plus a route test and a DB test for the mixed and already-in-album cases.

Record
  • I agree to follow this project's Code of Conduct
Dominant language
Python
Stars
322
Forks
793
Avg merge
6d 9h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/PictoPy

All issues in AOSSIE-Org/PictoPy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.