Error 500 when opening the gallery #2385

Closed
opened 2026-02-05 03:53:32 +03:00 by OVERLORD · 15 comments
Owner

Originally created by @awesome-michael on GitHub (Sep 10, 2021).

Describe the bug
When I try to insert an image on a page I get an error 500 from the server

Steps To Reproduce
Steps to reproduce the behavior:

  1. Edit a page
  2. Click on 'Insert an image'
  3. See error GET https://example.com/images/gallery?page=1&uploaded_to=142 500 in the browser console

Expected behavior
Gallery shows images that were uploaded

Screenshots
If applicable, add screenshots to help explain your problem.

Your Configuration (please complete the following information):

Additional context
I tried to debug the error but can't find anything related in the error logs at storage/logs/laravel.log and even setting the APP_DEBUG=true in the .env file didn't reveal any information on the error (I think the setting didn't change anything at all).

Originally created by @awesome-michael on GitHub (Sep 10, 2021). **Describe the bug** When I try to insert an image on a page I get an error 500 from the server **Steps To Reproduce** Steps to reproduce the behavior: 1. Edit a page 2. Click on 'Insert an image' 3. See error `GET https://example.com/images/gallery?page=1&uploaded_to=142 500` in the browser console **Expected behavior** Gallery shows images that were uploaded **Screenshots** If applicable, add screenshots to help explain your problem. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): BookStack v21.08.2 - PHP Version: 7.4.23 - Hosting Method (Nginx/Apache/Docker): Docker Image from here: https://hub.docker.com/r/linuxserver/bookstack **Additional context** I tried to debug the error but can't find anything related in the error logs at storage/logs/laravel.log and even setting the APP_DEBUG=true in the .env file didn't reveal any information on the error (I think the setting didn't change anything at all).
Author
Owner

@ssddanbrown commented on GitHub (Sep 12, 2021):

Hi @awesome-michael,

  • Are you able to add and remove attachments okay on your instance?
  • Do you have any web development experience/skills? (Just for me when thinking of next steps to help debug.)
@ssddanbrown commented on GitHub (Sep 12, 2021): Hi @awesome-michael, - Are you able to add and remove attachments okay on your instance? - Do you have any web development experience/skills? (Just for me when thinking of next steps to help debug.)
Author
Owner

@awesome-michael commented on GitHub (Sep 12, 2021):

Hi @ssddanbrown,

  • Yes, adding and removing attachments works without problems, I also noticed that I can upload images and they show up in the "insert image" menu under the book or page tab. But the "all" tab still generates the error 500
  • Yes I have development experience. I just can't get the app to log the error properly (or I'm not able to find the log) so I have no idea where to start debugging.
@awesome-michael commented on GitHub (Sep 12, 2021): Hi @ssddanbrown, - Yes, adding and removing attachments works without problems, I also noticed that I can upload images and they show up in the "insert image" menu under the book or page tab. But the "all" tab still generates the error 500 - Yes I have development experience. I just can't get the app to log the error properly (or I'm not able to find the log) so I have no idea where to start debugging.
Author
Owner

@ssddanbrown commented on GitHub (Sep 13, 2021):

@awesome-michael Something to try below. I suspect this is either due to query parameters not being passed as expected (Can occur when there's a slight proxy/webserver misconfiguration) or a particular image is causing trouble when a thumbnail is attempting to be generated.

  • Could you take a screenshot of what's visible when you access the https://example.com/images/gallery?page=1&uploaded_to=142 URL directly (But on your instance)? Just want to understand the level at which this is generated, hoping the error screen can provide some clues.
  • Does the search system work okay? Or does it show the same results no matter the search term?
@ssddanbrown commented on GitHub (Sep 13, 2021): @awesome-michael Something to try below. I suspect this is either due to query parameters not being passed as expected (Can occur when there's a slight proxy/webserver misconfiguration) or a particular image is causing trouble when a thumbnail is attempting to be generated. - Could you take a screenshot of what's visible when you access the `https://example.com/images/gallery?page=1&uploaded_to=142` URL directly (But on your instance)? Just want to understand the level at which this is generated, hoping the error screen can provide some clues. - Does the search system work okay? Or does it show the same results no matter the search term?
Author
Owner

@awesome-michael commented on GitHub (Sep 17, 2021):

  • When accessing the URL directly the browser just shows the error 500.. no additional error message
  • The search works just fine, no errors
    error500
@awesome-michael commented on GitHub (Sep 17, 2021): - When accessing the URL directly the browser just shows the error 500.. no additional error message - The search works just fine, no errors ![error500](https://user-images.githubusercontent.com/37796947/133738584-554ba5c4-3c20-4c62-9cf4-a683ff7e1296.jpg)
Author
Owner

@ssddanbrown commented on GitHub (Sep 18, 2021):

Hi @awesome-michael,
This is not an error being handled at a BookStack level, but more likely at a webserver level. You'll need to check your webserver's error logs. Since you're using a docker setup keep in mind that you'll likely have mulitple web-servers at play (One inside and one outside the container).

@ssddanbrown commented on GitHub (Sep 18, 2021): Hi @awesome-michael, This is not an error being handled at a BookStack level, but more likely at a webserver level. You'll need to check your webserver's error logs. Since you're using a docker setup keep in mind that you'll likely have mulitple web-servers at play (One inside and one outside the container).
Author
Owner

@ssddanbrown commented on GitHub (Sep 29, 2021):

Since there's been no follow-up I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.

@ssddanbrown commented on GitHub (Sep 29, 2021): Since there's been no follow-up I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.
Author
Owner

@badsmoke commented on GitHub (Aug 21, 2023):

we now have the same problem

this error message appears in the console

browser console log:

GET https://wiki.domain.com/subdir/images/gallery?page=1&uploaded_to=474 500

app.js?version=v23.06.2:18 Uncaught (in promise) Error
    at No (app.js?version=v23.06.2:18:1440)
    at async tn.loadGallery (app.js?version=v23.06.2:19:76647)

but it has definitely worked before.

bookstack runs behind an nginx and a subdir

thank you

@badsmoke commented on GitHub (Aug 21, 2023): we now have the same problem this error message appears in the console browser console log: ```` GET https://wiki.domain.com/subdir/images/gallery?page=1&uploaded_to=474 500 app.js?version=v23.06.2:18 Uncaught (in promise) Error at No (app.js?version=v23.06.2:18:1440) at async tn.loadGallery (app.js?version=v23.06.2:19:76647) ```` but it has definitely worked before. bookstack runs behind an nginx and a subdir thank you
Author
Owner

@al-cheb commented on GitHub (Aug 22, 2023):

@ssddanbrown, @badsmoke
In my case I have uploaded a high resolution png(16000x16000) file ~ 8mb and after that I got the 500 error.

Steps to reproduce:

  1. Upload image https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2F9clb0corsmr81.png
  2. Check that the file has been uploaded
www-data@bookstack-579844c674-rbwbg:~/bookstack$ ls -lah public/uploads/images/gallery/2023-08/9clb0corsmr81.png 
-rw-r--r-- 1 www-data www-data 6.9M Aug 21 20:51 public/uploads/images/gallery/2023-08/9clb0corsmr81.png
  1. Image Select returns 500
  2. Remove the local file
www-data@bookstack-579844c674-rbwbg:~/bookstack$ rm public/uploads/images/gallery/2023-08/9clb0corsmr81.png
  1. Image Select returns 200

I know this case is very rare but it's difficult to debug such kind behavior and easy to block the Image Selector .

@al-cheb commented on GitHub (Aug 22, 2023): @ssddanbrown, @badsmoke In my case I have uploaded a high resolution png(16000x16000) file ~ 8mb and after that I got the 500 error. Steps to reproduce: 1. Upload image https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2F9clb0corsmr81.png 2. Check that the file has been uploaded ``` www-data@bookstack-579844c674-rbwbg:~/bookstack$ ls -lah public/uploads/images/gallery/2023-08/9clb0corsmr81.png -rw-r--r-- 1 www-data www-data 6.9M Aug 21 20:51 public/uploads/images/gallery/2023-08/9clb0corsmr81.png ``` 3. Image Select returns 500 4. Remove the local file ``` www-data@bookstack-579844c674-rbwbg:~/bookstack$ rm public/uploads/images/gallery/2023-08/9clb0corsmr81.png ``` 5. Image Select returns 200 I know this case is very rare but it's difficult to debug such kind behavior and easy to block the Image Selector .
Author
Owner

@ssddanbrown commented on GitHub (Aug 22, 2023):

Yeah, large images can lead to memory being exhausted when attempting to resize.
Maybe we should force fail upon upload in these scenarios with applicable warning, will have to test how easy it is to catch since it's an out-of-memory situation.

@ssddanbrown commented on GitHub (Aug 22, 2023): Yeah, large images can lead to memory being exhausted when attempting to resize. Maybe we should force fail upon upload in these scenarios with applicable warning, will have to test how easy it is to catch since it's an out-of-memory situation.
Author
Owner

@al-cheb commented on GitHub (Aug 22, 2023):

Yeah, it would be great if we have a warning on upload and replace a preview icon if a file can't be properly displayed to make it easy to find .

@al-cheb commented on GitHub (Aug 22, 2023): Yeah, it would be great if we have a warning on upload and replace a preview icon if a file can't be properly displayed to make it easy to find .
Author
Owner

@ssddanbrown commented on GitHub (Aug 22, 2023):

@al-cheb I'd probably just prevent the upload entirely (with a better warning/error message) if it can't be resized, rather than add control to set a custom preview icon. We also resize to make the image used within content reasonable. I don't want to end up where users can easily upload and use massive multi-MB in content. Can always resort to attachments instead if a massive image really does need to be uploaded.

@ssddanbrown commented on GitHub (Aug 22, 2023): @al-cheb I'd probably just prevent the upload entirely (with a better warning/error message) if it can't be resized, rather than add control to set a custom preview icon. We also resize to make the image used within content reasonable. I don't want to end up where users can easily upload and use massive multi-MB in content. Can always resort to attachments instead if a massive image really does need to be uploaded.
Author
Owner

@ssddanbrown commented on GitHub (Aug 22, 2023):

I've opened up #4454 as an intent to improve things as discussed above, which is assigned to a future maintenance release.

@ssddanbrown commented on GitHub (Aug 22, 2023): I've opened up #4454 as an intent to improve things as discussed above, which is assigned to a future maintenance release.
Author
Owner

@badsmoke commented on GitHub (Aug 22, 2023):

you guys are great, I write just before going to sleep and when I wake up you have already taken care of it :-D

i just checked, the files are all about 2.7mb in size, when i delete them the gallery loads again.

when uploading again, comes the error

POST https://wiki.domain.com/images/gallery?uploaded_to=474 500

I also see no cpu or ram load when uploading

@badsmoke commented on GitHub (Aug 22, 2023): you guys are great, I write just before going to sleep and when I wake up you have already taken care of it :-D i just checked, the files are all about 2.7mb in size, when i delete them the gallery loads again. when uploading again, comes the error `POST https://wiki.domain.com/images/gallery?uploaded_to=474 500` I also see no cpu or ram load when uploading
Author
Owner

@ssddanbrown commented on GitHub (Aug 22, 2023):

@badsmoke

I also see no cpu or ram load when uploading

It's probably hard to observe since the default PHP RAM limit is often small and this will only spike for a very quick moment.

The PHP option memory_limit defaults to 128MB in most cases, increasing this option (usually via a relevant php.ini file) can help handle much larger images.

@ssddanbrown commented on GitHub (Aug 22, 2023): @badsmoke > I also see no cpu or ram load when uploading It's probably hard to observe since the default PHP RAM limit is often small and this will only spike for a very quick moment. The PHP option `memory_limit` defaults to 128MB in most cases, increasing this option (usually via a relevant `php.ini` file) can help handle much larger images.
Author
Owner

@badsmoke commented on GitHub (Aug 28, 2023):

thank you, a increasing has solved the problem

@badsmoke commented on GitHub (Aug 28, 2023): thank you, a increasing has solved the problem
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2385