API Endpoint /search/statistics returns 500: Internal Server Error if personIds is provided #8188

Closed
opened 2026-02-05 13:35:10 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @Skeletrin on GitHub (Jan 4, 2026).

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

I'm trying to retrieve statistics of people using the api. However if I use the endpoint "/search/statistics" and provide personIds the request returns an Internal Server Error 500 with the message: "Failed to search asset statistics".
This happens both on my instance as well as on the live response test using the demo server (https://api.immich.app/endpoints/search/searchAssetStatistics).

The OS that Immich Server is running on

Windows

Version of Immich Server

v2.4.1

Version of Immich Mobile App

v2.4.1

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

No response

Your docker-compose.yml content

#
# WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose
#
# Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    volumes:
      # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - '2283:2283'
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    healthcheck:
      test: >-
        pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" || exit 1; Chksum="$$(psql --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
      interval: 5m
      start_interval: 30s
      start_period: 5m
    command: >-
      postgres -c shared_preload_libraries=vectors.so -c 'search_path="$$user", public, vectors' -c logging_collector=on -c max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on
    restart: always

volumes:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location where your database files are stored
DB_DATA_LOCATION=./postgres

# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
TZ=Europe/Berlin

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=
# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=
DB_DATABASE_NAME=

Reproduction steps

  1. Have a running server instance
  2. Create api-key with at least permission: asset.statistics
  3. target api endpoint: /search/statistics (https://api.immich.app/endpoints/search/searchAssetStatistics).
  4. Send post request with the following body, (any correctly formatted UUID):
{
"personIds":["ef616dcf-dcd1-41ed-998b-7ffa8933c5d2"]
}
  1. Receive Error Code 500 response

Relevant log output

2026-01-03 22:48:53 immich_server            | [Nest] 33  - 01/03/2026, 10:48:53 PM   ERROR [Api:ErrorInterceptor~meyy1yzo] Unknown error: PostgresError: subquery uses ungrouped column "asset.id" from outer query
2026-01-03 22:48:53 immich_server            | PostgresError: subquery uses ungrouped column "asset.id" from outer query
2026-01-03 22:48:53 immich_server            |     at ErrorResponse (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:794:26)
2026-01-03 22:48:53 immich_server            |     at handle (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:480:6)
2026-01-03 22:48:53 immich_server            |     at Socket.data (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:315:9)
2026-01-03 22:48:53 immich_server            |     at Socket.emit (node:events:518:28)
2026-01-03 22:48:53 immich_server            |     at addChunk (node:internal/streams/readable:561:12)
2026-01-03 22:48:53 immich_server            |     at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
2026-01-03 22:48:53 immich_server            |     at Readable.push (node:internal/streams/readable:392:5)
2026-01-03 22:48:53 immich_server            |     at TCP.onStreamRead (node:internal/stream_base_commons:189:23)
2026-01-03 22:48:53 immich_server            |     at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
2026-01-03 22:48:53 immich_server            | Query failed : {
2026-01-03 22:48:53 immich_server            |   durationMs: 0.43160100001841784,
2026-01-03 22:48:53 immich_server            |   error: PostgresError: subquery uses ungrouped column "asset.id" from outer query
2026-01-03 22:48:53 immich_server            |       at ErrorResponse (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:794:26)
2026-01-03 22:48:53 immich_server            |       at handle (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:480:6)
2026-01-03 22:48:53 immich_server            |       at Socket.data (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:315:9)
2026-01-03 22:48:53 immich_server            |       at Socket.emit (node:events:518:28)
2026-01-03 22:48:53 immich_server            |       at addChunk (node:internal/streams/readable:561:12)
2026-01-03 22:48:53 immich_server            |       at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
2026-01-03 22:48:53 immich_server            |       at Readable.push (node:internal/streams/readable:392:5)
2026-01-03 22:48:53 immich_server            |       at TCP.onStreamRead (node:internal/stream_base_commons:189:23)
2026-01-03 22:48:53 immich_server            |       at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
2026-01-03 22:48:53 immich_server            |     severity_local: 'ERROR',
2026-01-03 22:48:53 immich_server            |     severity: 'ERROR',
2026-01-03 22:48:53 immich_server            |     code: '42803',
2026-01-03 22:48:53 immich_server            |     position: '263',
2026-01-03 22:48:53 immich_server            |     file: 'parse_agg.c',
2026-01-03 22:48:53 immich_server            |     line: '1429',
2026-01-03 22:48:53 immich_server            |     routine: 'check_ungrouped_columns_walker'
2026-01-03 22:48:53 immich_server            |   },
2026-01-03 22:48:53 immich_server            |   sql: `select (select coalesce(json_agg(agg), '[]') from (select "asset_face".*, "person" as "person" from "asset_face" left join lateral (select "person".* from "person" where "asset_face"."personId" = "person"."id") as "person" on true where "asset_face"."assetId" = "asset"."id" and "asset_face"."deletedAt" is null) as agg) as "faces", count(*) as "total" from "asset" inner join (select "assetId" from "asset_face" where "personId" = any($1::uuid[]) and "deletedAt" is null group by "assetId" having count(distinct "personId") = $2) as "has_people" on "has_people"."assetId" = "asset"."id" where "asset"."visibility" = $3 and "asset"."ownerId" = any($4::uuid[]) and "asset"."deletedAt" is null`,
2026-01-03 22:48:53 immich_server            |   params: [
2026-01-03 22:48:53 immich_server            |     '{d43f99d2-6ca4-45ae-87bf-e6e3ab03dc55}',
2026-01-03 22:48:53 immich_server            |     1,
2026-01-03 22:48:53 immich_server            |     'timeline',
2026-01-03 22:48:53 immich_server            |     '{67d5d31f-102c-415e-b8a1-9ffe50239e55}'
2026-01-03 22:48:53 immich_server            |   ]
2026-01-03 22:48:53 immich_server            | }

Additional information

No response

Originally created by @Skeletrin on GitHub (Jan 4, 2026). ### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug I'm trying to retrieve statistics of people using the api. However if I use the endpoint "/search/statistics" and provide personIds the request returns an Internal Server Error 500 with the message: "Failed to search asset statistics". This happens both on my instance as well as on the live response test using the demo server (https://api.immich.app/endpoints/search/searchAssetStatistics). ### The OS that Immich Server is running on Windows ### Version of Immich Server v2.4.1 ### Version of Immich Mobile App v2.4.1 ### Platform with the issue - [x] Server - [ ] Web - [ ] Mobile ### Device make and model _No response_ ### Your docker-compose.yml content ```YAML # # WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose # # Make sure to use the docker-compose.yml of the current release: # # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml # # The compose file on main may not be compatible with the latest release. name: immich services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} # extends: # file: hwaccel.transcoding.yml # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding volumes: # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - '2283:2283' depends_on: - redis - database restart: always healthcheck: disable: false immich-machine-learning: container_name: immich_machine_learning # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. # Example tag: ${IMMICH_VERSION:-release}-cuda image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration # file: hwaccel.ml.yml # service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable volumes: - model-cache:/cache env_file: - .env restart: always healthcheck: disable: false redis: container_name: immich_redis image: docker.io/redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8 healthcheck: test: redis-cli ping || exit 1 restart: always database: container_name: immich_postgres image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52 environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' volumes: # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file - ${DB_DATA_LOCATION}:/var/lib/postgresql/data healthcheck: test: >- pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" || exit 1; Chksum="$$(psql --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1 interval: 5m start_interval: 30s start_period: 5m command: >- postgres -c shared_preload_libraries=vectors.so -c 'search_path="$$user", public, vectors' -c logging_collector=on -c max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on restart: always volumes: model-cache: ``` ### Your .env content ```Shell # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables # The location where your uploaded files are stored UPLOAD_LOCATION=./library # The location where your database files are stored DB_DATA_LOCATION=./postgres # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List TZ=Europe/Berlin # The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release # Connection secret for postgres. You should change it to a random password # Please use only the characters `A-Za-z0-9`, without special characters or spaces DB_PASSWORD= # The values below this line do not need to be changed ################################################################################### DB_USERNAME= DB_DATABASE_NAME= ``` ### Reproduction steps 1. Have a running server instance 2. Create api-key with at least permission: asset.statistics 3. target api endpoint: /search/statistics (https://api.immich.app/endpoints/search/searchAssetStatistics). 4. Send post request with the following body, (any correctly formatted UUID): ``` { "personIds":["ef616dcf-dcd1-41ed-998b-7ffa8933c5d2"] } ``` 5. Receive Error Code 500 response ### Relevant log output ```shell 2026-01-03 22:48:53 immich_server | [Nest] 33 - 01/03/2026, 10:48:53 PM ERROR [Api:ErrorInterceptor~meyy1yzo] Unknown error: PostgresError: subquery uses ungrouped column "asset.id" from outer query 2026-01-03 22:48:53 immich_server | PostgresError: subquery uses ungrouped column "asset.id" from outer query 2026-01-03 22:48:53 immich_server | at ErrorResponse (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:794:26) 2026-01-03 22:48:53 immich_server | at handle (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:480:6) 2026-01-03 22:48:53 immich_server | at Socket.data (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:315:9) 2026-01-03 22:48:53 immich_server | at Socket.emit (node:events:518:28) 2026-01-03 22:48:53 immich_server | at addChunk (node:internal/streams/readable:561:12) 2026-01-03 22:48:53 immich_server | at readableAddChunkPushByteMode (node:internal/streams/readable:512:3) 2026-01-03 22:48:53 immich_server | at Readable.push (node:internal/streams/readable:392:5) 2026-01-03 22:48:53 immich_server | at TCP.onStreamRead (node:internal/stream_base_commons:189:23) 2026-01-03 22:48:53 immich_server | at TCP.callbackTrampoline (node:internal/async_hooks:130:17) 2026-01-03 22:48:53 immich_server | Query failed : { 2026-01-03 22:48:53 immich_server | durationMs: 0.43160100001841784, 2026-01-03 22:48:53 immich_server | error: PostgresError: subquery uses ungrouped column "asset.id" from outer query 2026-01-03 22:48:53 immich_server | at ErrorResponse (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:794:26) 2026-01-03 22:48:53 immich_server | at handle (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:480:6) 2026-01-03 22:48:53 immich_server | at Socket.data (/usr/src/app/server/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/connection.js:315:9) 2026-01-03 22:48:53 immich_server | at Socket.emit (node:events:518:28) 2026-01-03 22:48:53 immich_server | at addChunk (node:internal/streams/readable:561:12) 2026-01-03 22:48:53 immich_server | at readableAddChunkPushByteMode (node:internal/streams/readable:512:3) 2026-01-03 22:48:53 immich_server | at Readable.push (node:internal/streams/readable:392:5) 2026-01-03 22:48:53 immich_server | at TCP.onStreamRead (node:internal/stream_base_commons:189:23) 2026-01-03 22:48:53 immich_server | at TCP.callbackTrampoline (node:internal/async_hooks:130:17) { 2026-01-03 22:48:53 immich_server | severity_local: 'ERROR', 2026-01-03 22:48:53 immich_server | severity: 'ERROR', 2026-01-03 22:48:53 immich_server | code: '42803', 2026-01-03 22:48:53 immich_server | position: '263', 2026-01-03 22:48:53 immich_server | file: 'parse_agg.c', 2026-01-03 22:48:53 immich_server | line: '1429', 2026-01-03 22:48:53 immich_server | routine: 'check_ungrouped_columns_walker' 2026-01-03 22:48:53 immich_server | }, 2026-01-03 22:48:53 immich_server | sql: `select (select coalesce(json_agg(agg), '[]') from (select "asset_face".*, "person" as "person" from "asset_face" left join lateral (select "person".* from "person" where "asset_face"."personId" = "person"."id") as "person" on true where "asset_face"."assetId" = "asset"."id" and "asset_face"."deletedAt" is null) as agg) as "faces", count(*) as "total" from "asset" inner join (select "assetId" from "asset_face" where "personId" = any($1::uuid[]) and "deletedAt" is null group by "assetId" having count(distinct "personId") = $2) as "has_people" on "has_people"."assetId" = "asset"."id" where "asset"."visibility" = $3 and "asset"."ownerId" = any($4::uuid[]) and "asset"."deletedAt" is null`, 2026-01-03 22:48:53 immich_server | params: [ 2026-01-03 22:48:53 immich_server | '{d43f99d2-6ca4-45ae-87bf-e6e3ab03dc55}', 2026-01-03 22:48:53 immich_server | 1, 2026-01-03 22:48:53 immich_server | 'timeline', 2026-01-03 22:48:53 immich_server | '{67d5d31f-102c-415e-b8a1-9ffe50239e55}' 2026-01-03 22:48:53 immich_server | ] 2026-01-03 22:48:53 immich_server | } ``` ### Additional information _No response_
Author
Owner

@omkarg01 commented on GitHub (Jan 4, 2026):

Hi, I would like to work on this issue.

@omkarg01 commented on GitHub (Jan 4, 2026): Hi, I would like to work on this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#8188