immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
42.57k stars 2.08k forks source link

[BUG] iOS App Repeatedly Uploading to Immich Server and Failing - Error in Finding AssetEntity Entity Type #2269

Closed JustAmply closed 1 year ago

JustAmply commented 1 year ago

The bug

When using the iOS app to upload images to Immich, I faced an issue where the app repeatedly attempted to upload while failing to do so. Earlier, I had successfully used the cli tool to upload my existing nextcloud-library to Immich. However, a significant number of pictures in the library lacked metadata such as dates and locations, which might or might not be related to the issue I face.

Despite successfully uploading many pictures, the app's counters "Backup" and "Remainder" remain static. Upon examining the error log of the immich-server container, I discovered that the app was encountering an error. Specifically, it failed to locate any entity of type "AssetEntity" that matched the parameters specified in the error message. It appears that the app kept trying to upload the already uploaded files because it could not recognize them.

Error logs are attached below.

The OS that Immich Server is running on

Debian

Version of Immich Server

v1.53.0

Version of Immich Mobile App

v1.53.0 build.93

Platform with the issue

Your docker-compose.yml content

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:release
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    env_file:
      - .env
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.0
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    logging:
      driver: none
    volumes:
      - tsdata:/data
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:release
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    logging:
      driver: none
    depends_on:
      - immich-server
    restart: always

volumes:
  pgdata:
  model-cache:
  tsdata:

Your .env content

DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
REDIS_HOSTNAME=immich_redis
UPLOAD_LOCATION=/mnt/photos/app/immich/upload
TYPESENSE_API_KEY=REDACTED
PUBLIC_LOGIN_PAGE_MESSAGE="REDACTED"
IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

Reproduction steps

1. Upload images from Nextcloud to Immich with CLI
2. Try to upload already uploaded photos from iPhone to Immich with the app
3. Error!

Additional information

Error of Container immich-server:

[Nest] 1  - 04/17/2023, 3:15:40 PM   ERROR [ExceptionsHandler] Could not find any entity of type "AssetEntity" matching: {
    "where": {
        "ownerId": "21bc6e60-20d5-4e06-8922-45fd7d9afd98",
        "checksum": {
            "type": "Buffer",
            "data": [
                111,
                207,
                42,
                2,
                186,
                80,
                90,
                194,
                124,
                124,
                110,
                91,
                6,
                109,
                241,
                43,
                86,
                206,
                85,
undefined 
            ]
        }
    },
    "relations": [
undefined | 0=e 1=x 2=i 3=f 4=I 5=n 6=f 7=o 
    ]
}
EntityNotFoundError: Could not find any entity of type "AssetEntity" matching: {
    "where": {
        "ownerId": "21bc6e60-20d5-4e06-8922-45fd7d9afd98",
        "checksum": {
            "type": "Buffer",
            "data": [
                111,
                207,
                42,
                2,
                186,
                80,
                90,
                194,
                124,
                124,
                110,
                91,
                6,
                109,
                241,
                43,
                86,
                206,
                85,
undefined 
            ]
        }
    },
    "relations": [
undefined | 0=e 1=x 2=i 3=f 4=I 5=n 6=f 7=o 
    ]
}
    at /usr/src/app/node_modules/typeorm/entity-manager/EntityManager.js:638:39
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async AssetService.uploadFile (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/asset/asset.service.js:72:35)
    at async AssetController.uploadFile (/usr/src/app/dist/apps/immich/apps/immich/src/api-v1/asset/asset.controller.js:62:29)

Error shown in the iOS app:

Don't know if this is related...

Message Null check operator used on a null value From ImmichErrorLogger Stack Traces

#0      SyncService._syncAlbumInDbAndOnDevice (package:immich_mobile/shared/services/sync.service.dart:450)
<asynchronous suspension>
#1      diffSortedLists (package:immich_mobile/utils/diff.dart:19)
<asynchronous suspension>
#2      SyncService._syncLocalAlbumAssetsToDb (package:immich_mobile/shared/services/sync.service.dart:377)
<asynchronous suspension>
#3      AlbumService.refreshDeviceAlbums (package:immich_mobile/modules/album/services/album.service.dart:113)
<asynchronous suspension>
#4      AssetNotifier.getAllAsset (package:immich_mobile/shared/providers/asset.provider.dart:114)
<asynchronous suspension>
JustAmply commented 1 year ago

I found issue #1960 with the same error. Most likely duplicate. Here's just more context

JustAmply commented 1 year ago

The error I encounter looks the same as shown in the following video. https://github.com/immich-app/immich/issues/1902#issuecomment-1449367768

Their fix didn't work for me, though.

paveldudka commented 1 year ago

yeah, currently server doesn't handle dups well. See https://discord.com/channels/979116623879368755/1096683207539314899/1097221557270626354

JustAmply commented 1 year ago

It looks like the issue is fixed in v1.58.0! Am currently uploading all remaining photos, great work everyone ❤

jrasm91 commented 1 year ago

Fixed in #2072