simulot / immich-go

An alternative to the immich-CLI command that doesn't depend on nodejs installation. It tries its best for importing google photos takeout archives.
GNU Affero General Public License v3.0
1.93k stars 55 forks source link

duplicate function lists duplicate but fails to delete them => Can't delete asset: DeleteAsset, DELETE 400 Bad Request #223

Open MrColumbo opened 7 months ago

MrColumbo commented 7 months ago

After moving more and more stuff to Immich I wanted to use the duplicate function of immich-go since i used that tool to upload a lot of photos.

When I try it i get results but whenever i select yes i get an error

For example it looks like that:

immich-go -server http://192.168.178.186:2283 -key ####################### duplicate

There are 2 copies of the asset 222.JPG.JPG, taken on 1970-04-16T22:22:45+01:00 delete 222.JPG 2048x1536, 370.8 KB, upload/library/692a9ac8-b728-4c8a-897d-6c84c94c2053/1970/1970-04-16/222.JPG keep 222.JPG 2048x1536, 370.8 KB, upload/library/f129e4df-22fb-4000-b3ce-3f8fe2412698/1970/1970-04-16/222.JPG Proceed? [n]/y: y Can't delete asset: DeleteAsset, DELETE, http://192.168.178.186:2283/api/asset, 400 Bad Request Bad Request

Since i am doing that locally without the reverse proxy i was able to sniff the traffic ....the actual HTTP traffic looks like that

DELETE /api/asset HTTP/1.1 Host: 192.168.178.186:2283 User-Agent: Go-http-client/1.1 Transfer-Encoding: chunked Accept: application/json Content-Type: application/json X-Api-Key: ######################################### Accept-Encoding: gzip

{"force":false,"ids":["###################"]} HTTP/1.1 400 Bad Request X-Powered-By: Express x-immich-cid: pxu7smfs Content-Type: application/json; charset=utf-8 Content-Length: 88 ETag: "#######################" Date: Sat, 20 Apr 2024 14:17:51 GMT Connection: keep-alive Keep-Alive: timeout=5

{"message":"Not found or no asset.delete access","error":"Bad Request","statusCode":400}GET /api/album?assetId=############################### HTTP/1.1 Host: 192.168.178.186:2283 User-Agent: Go-http-client/1.1 Accept: application/json X-Api-Key: ###################################### Accept-Encoding: gzip

using the search function and the filename and date I found the 2 duplicates ....they really exist

MrColumbo commented 7 months ago

since i found the 2 files via search i thought lets have a look if i am able to delete them via the gui - well - i am not able to delete them via the gui either. . I guess the 2 assets are from my partner.

Is the duplicate returning results which are read only for the user owning the api key used to run the command? Somehow it is nice to those but at the same time i feel it does make sense to ask the user with read only access if it fine to delete them ;) Or do I miss something?

MrColumbo commented 7 months ago

i did ran the command again with the other api key and now it works

MrColumbo commented 7 months ago

it gets quite funny when there is a duplicate when there is one in your account in one in your partner account and immich-go decides to keep the one which it could delete but wants to delete the one from your partner. I looks like it even does that when i use the api key from my partner ....

simulot commented 7 months ago

Interesting case. The duplicate search is done on the list of assets delivered by the api. It may happen that partner's photos are included. That would explain the deletion error.

MrColumbo commented 6 months ago

I agree - the API obviously returns the partner images as well and I consider this as a benefit / feature to be able to look for duplicates in all assets (accessible to you) but unfortunately the client does not seem to recognize when results return assets where one asset belongs to the partner and one belongs to you. I wish there would be a switch to tell the client to keep the partner assets and delete your assets or ignore those. Thinking a bit more about it I think it might be also nice to have a way to prefer to keep the ones being part of an album.

sbkg0002 commented 2 weeks ago

I also just ran into this. Is there a way to make it non-fatal? Now my imports break because of this.

simulot commented 2 weeks ago

Not really, this denotes a problem with immich go.

Is the asset to be deleted from a shared album ?

Could you share the immich-go version and the immich server version? Could you enable the -trace-api and share the details of the error?

sbkg0002 commented 2 weeks ago

The asset was from a shared album. So I ended up filtering out the file from the upload and continued.

Thanks for the reply!