[BUG] server: cannot access asset resources #1450

Closed
opened 2026-02-05 01:52:59 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @waclaw66 on GitHub (Oct 13, 2023).

Originally assigned to: @jrasm91 on GitHub.

The bug

While debugging immich-server I've discovered that many filesystem routines access assets by relative path only.
f0bb50b61a/server/src/immich/api-v1/asset/asset.service.ts (L431)
In the above example an asset is checked for availability by the relative path like upload/thumbs/82b637ca-7ad6-43cd-a15d-aad029fc87f2/89/36/8936b4dc-a251-43ba-992e-70a171bc8b05.jpeg only. If the server process runs from different directory than root of the assets library (my case, because of starting debug manually by npm run start:debug immich from server source directory), assets cannot be accessed by relative path. In the next step a file is read with the full path, however library root is taken from the current dir of the server process (why??)...
f0bb50b61a/server/src/immich/api-v1/asset/asset.service.ts (L432)

Those relative paths should be refactored to use the environment variable UPLOAD_LOCATION as library root to avoid having to run the server process from the library directory.

The OS that Immich Server is running on

Fedora 38

Version of Immich Server

v1.81.1

Version of Immich Mobile App

not relevant

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

not using Docker

Your .env content

UPLOAD_LOCATION=/var/lib/immich/upload

Reproduction steps

not relevant

Additional information

No response

Originally created by @waclaw66 on GitHub (Oct 13, 2023). Originally assigned to: @jrasm91 on GitHub. ### The bug While debugging immich-server I've discovered that many filesystem routines access assets by relative path only. https://github.com/immich-app/immich/blob/f0bb50b61a7584d733df40ab7a71a580d26656fc/server/src/immich/api-v1/asset/asset.service.ts#L431 In the above example an asset is checked for availability by the relative path like `upload/thumbs/82b637ca-7ad6-43cd-a15d-aad029fc87f2/89/36/8936b4dc-a251-43ba-992e-70a171bc8b05.jpeg` only. If the server process runs from different directory than root of the assets library (my case, because of starting debug manually by `npm run start:debug immich` from `server` source directory), assets cannot be accessed by relative path. In the next step a file is read with the full path, however library root is taken from the current dir of the server process (why??)... https://github.com/immich-app/immich/blob/f0bb50b61a7584d733df40ab7a71a580d26656fc/server/src/immich/api-v1/asset/asset.service.ts#L432 Those relative paths should be refactored to use the environment variable `UPLOAD_LOCATION` as library root to avoid having to run the server process from the library directory. ### The OS that Immich Server is running on Fedora 38 ### Version of Immich Server v1.81.1 ### Version of Immich Mobile App not relevant ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML not using Docker ``` ### Your .env content ```Shell UPLOAD_LOCATION=/var/lib/immich/upload ``` ### Reproduction steps ```bash not relevant ``` ### Additional information _No response_
Author
Owner

@bo0tzz commented on GitHub (Oct 13, 2023):

The storage root is meant to be taken from the APP_MEDIA_LOCATION constant. This constant uses the value of the IMMICH_MEDIA_LOCATION env var, or ./upload if that is not set.

If there is file access code not using those fields, then that is probably an issue that needs fixing.

@bo0tzz commented on GitHub (Oct 13, 2023): The storage root is meant to be [taken from the `APP_MEDIA_LOCATION` constant](https://github.com/immich-app/immich/blob/f0bb50b61a7584d733df40ab7a71a580d26656fc/server/src/domain/storage/storage.core.ts#L42-L44). This constant uses [the value of the `IMMICH_MEDIA_LOCATION` env var, or `./upload` if that is not set](https://github.com/immich-app/immich/blob/f0bb50b61a7584d733df40ab7a71a580d26656fc/server/src/domain/domain.constant.ts#L24). If there is file access code not using those fields, then that is probably an issue that needs fixing.
Author
Owner

@mmomjian commented on GitHub (Jul 24, 2025):

This can be closed now right? Fixed in 1.136

@mmomjian commented on GitHub (Jul 24, 2025): This can be closed now right? Fixed in 1.136
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1450