Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addAssetsToAlbum endpoint does not handle repeated IDs #9368

Closed
bo0tzz opened this issue May 10, 2024 · 1 comment · Fixed by #9436
Closed

addAssetsToAlbum endpoint does not handle repeated IDs #9368

bo0tzz opened this issue May 10, 2024 · 1 comment · Fixed by #9436
Assignees
Labels
bug Something isn't working good first issue Good for newcomers 🗄️server

Comments

@bo0tzz
Copy link
Member

bo0tzz commented May 10, 2024

curl -X 'PUT' \
  'https://demo.immich.app/api/album/c757a1dc-afae-4cce-8f14-cf0adf5bea8e/assets' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "ids": [
    "7f7e71ab-a630-449d-b7c1-c52fc8b44733",
    "7f7e71ab-a630-449d-b7c1-c52fc8b44733"
  ]
}'

Results in

{
  "message": "Failed to add assets to album",
  "error": "Internal Server Error",
  "statusCode": 500
}

Because of this server error:

demo-immich-server-1            |     at async AlbumService.addAssets (/usr/src/app/dist/services/album.service.js:154:25)] Failed to add assets to album
demo-immich-server-1            | [Nest] 7  - 05/10/2024, 11:52:47 AM   ERROR [QueryFailedError: duplicate key value violates unique constraint "PK_c67bc36fa845fb7b18e0e398180"
demo-immich-server-1            |     at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
demo-immich-server-1            |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
demo-immich-server-1            |     at async InsertQueryBuilder.execute (/usr/src/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
demo-immich-server-1            |     at async AlbumRepository.addAssetIds (/usr/src/app/dist/repositories/album.repository.js:216:9)
demo-immich-server-1            |     at async addAssets (/usr/src/app/dist/utils/asset.util.js:29:9)
demo-immich-server-1            |     at async AlbumService.addAssets (/usr/src/app/dist/services/album.service.js:154:25)] QueryFailedError: duplicate key value violates unique constraint "PK_c67bc36fa845fb7b18e0e398180"

Repeated asset IDs should probably just get removed by using a Set.

@bo0tzz bo0tzz added bug Something isn't working good first issue Good for newcomers 🗄️server labels May 10, 2024
@eric-barch
Copy link
Contributor

If this is unclaimed, I'd like to take a stab at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers 🗄️server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants