immich-app / immich

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

[BUG] Import local files fails with 400 error #4286

Closed BurningTheSky closed 11 months ago

BurningTheSky commented 11 months ago

The bug

When using the upload --import command to add files already on the server I get a 400 error below:

root@e8df0c97ca93:/# immich upload --key <APIkey> --server http://192.168.0.37:8080/api --recursive photos/ --import

Checking connectivity with Immich instance...
Server status: OK
Checking credentials...
Login status: OK
Successful authentication for user xxxxxx
Indexing local assets...
Indexing complete, found 1 local assets
Comparing local assets with those on the Immich instance...
A total of 1 assets will be uploaded to the server
Do you want to start upload now? (y/n) y
Start uploading...
Upload Progress | ████████████████████████████████████████ | 100% || 1/1 || Current file [/photos/mac cover.jpg]
Error asset:  {
  file: '/photos/mac cover.jpg',
  reason: Error: Request failed with status code 400
      at createError (/app/cli/node_modules/axios/lib/core/createError.js:16:15)
      at settle (/app/cli/node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (/app/cli/node_modules/axios/lib/adapters/http.js:322:11)
      at IncomingMessage.emit (node:events:526:35)
      at endReadableNT (node:internal/streams/readable:1359:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    config: {
      transitional: [Object],
      adapter: [Function: httpAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: Infinity,
      maxBodyLength: Infinity,
      validateStatus: [Function: validateStatus],
      headers: [Object],
      method: 'post',
      maxRedirects: 0,
      url: 'http://192.168.0.37:8080/api/asset/import',
      data: '{"deviceAssetId":"maccover.jpg-106506","deviceId":"CLI","fileCreatedAt":"2023-09-30T11:09:17.322Z","fileModifiedAt":"2023-09-30T11:09:17.322Z","isFavorite":"false","fileExtension":".jpg","duration":"0:00:00.000000","isReadOnly":"true","assetPath":"/photos/mac cover.jpg"}'
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 271,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [Socket],
      _header: 'POST /api/asset/import HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'x-api-key: xxxxxxx\r\n' +
        'User-Agent: axios/0.26.1\r\n' +
        'Content-Length: 271\r\n' +
        'Host: 192.168.0.37:8080\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/api/asset/import',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: '192.168.0.37',
      protocol: 'http:',
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    response: {
      status: 400,
      statusText: 'Bad Request',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    },
    isAxiosError: true,
    toJSON: [Function: toJSON]
  },
  response: {
    message: [
      'libraryId must be a UUID',
      'libraryId should not be empty',
      'libraryId must be a string'
    ],
    error: 'Bad Request',
    statusCode: 400
  }
}

The OS that Immich Server is running on

Docker running on Unraid 6.12.4

Version of Immich Server

v1.79.1

Version of Immich Mobile App

N/A

Platform with the issue

Your docker-compose.yml content

Using Unraid so don't have a docker-compose.yml
Repository: ghcr.io/imagegenius/immich:latest
WebUI: 8080
Path: /photos: /mnt/user/Multimedia/Immich/
Path: /config/machine-learning: /mnt/user/Misc/ML
Path: /import: /mnt/user/Multimedia/PhotoImports
DB_HOSTNAME: 192.168.0.14
DB_USERNAME: <user>
DB_PASSWORD: <password>
DB_DATABASE_NAME: postgres
REDIS_HOSTNAME: localhost
DISABLE_MACHINE_LEARNING: false
DISABLE_TYPESENSE: false
DB_PORT: false
DB_PORT: 5432
REDIS_PORT: 6379
MACHINE_LEARNING_WORKERS: 1
MACHINE_LEARNING_WORKER_TIMEOUT: 120
Redis (DOCKER_MODS): imagegenius/mods:universal-redis

Your .env content

Don't seem to have one with unraid

Reproduction steps

1. add file to either photos/ or import/ folders
2. Run command immich upload --key xxxxx --server http://192.168.0.37:8080/api --recursive photos/ --import

Additional information

No response

danieldietzler commented 11 months ago

This should already be fixed by #4224. A next release containing this fix will be available in the next days.