Bulk Downloads from Photos App fail

Nextcloud version: 27.1.3
Operating system and version: Debian 12
Apache or nginx version (eg, Apache 2.4.25): nginx 1.22.1-9
PHP version (eg, 7.4): 8.2

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N):N

Steps to replicate it:

  1. Select one or more photos or videos from photos app
  2. Select download selected files
  3. Download fails with browser error Failed - Unknown server error. Please try again, or contact the server administrator.

Important to note that this only happens when using the multi-select download option, even when only selecting one item. You can individually download just fine by viewing the item, clicking the ellipsis and choosing download.

Relevant nginx error in error.log

Stack trace:
#0 {main}
  thrown in /var/www/nextcloud/apps/files/ajax/download.php on line 31" while reading response header from upstream, client:, server: mydomain.com  request: "GET /nextcloud/apps/files/ajax/download.php?files=%5B%22%2FInstantUpload%VERY_LONG_URL.mp4 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "mydomain.com"