LycheeOrg / Lychee

A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.
https://lycheeorg.github.io/
MIT License
3.42k stars 303 forks source link

Trouble dealing with a 500 Error, after updating to 4.2.2 #955

Closed flow7 closed 2 years ago

flow7 commented 3 years ago

Detailed description of the problem

Alright, I already run Lychee 4.X on Uberspace - the first install a while ago was painful, but in the end it worked.

Now, updating to 4.2.2: I've run the update according to the documentation: Update using Git, updating via GUI didn't work for some reason.

After the Update my page photos.domain.org only shows the black screen, with a short pop-up error message: "Server Error or API missing."

Any suggestions are greatly appreciated, thanks!

Update

git pull worked

composer install --no-dev comes back with a longer message:

composer install --no-dev
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

Discovered Package: bepsvpt/secure-headers
Discovered Package: darkghosthunter/larapass
Discovered Package: fideloper/proxy
Discovered Package: graham-campbell/markdown
Discovered Package: kalnoy/nestedset
Discovered Package: livewire/livewire
Discovered Package: nesbot/carbon
Discovered Package: spatie/laravel-feed
Discovered Package: spatie/laravel-image-optimizer
Package manifest generated successfully.
> sh install_files.sh
\n\033[38;5;011mcreating file for css personalization\033[0m
touch public/dist/user.css
\n\033[38;5;011mcreating default sqlite database\033[0m
touch database/database.sqlite
\n\033[38;5;011msetting up hooks for git pull and git commits\033[0m
cp pre-commit .git/hooks/
cp post-merge .git/hooks/
\n\033[38;5;214mTo disable the call of composer and migration on pull add\033[0m
\033[38;5;214ma file named '.NO_AUTO_COMPOSER_MIGRATE' in this directory.\033[0m\n
67 packages you are using are looking for funding.

php artisan migrate did work fine, and now responds "Nothing to migrate".

Now, heading over to photos.domain.org - doesn't work.

Diagnostics:

Web Diagnostics don't work, same error as above. Terminal Diagnostics show the following:

Diagnostics
-----------
Warning: lossless_optimization set to 1 but cwebp not found!
Warning: lossless_optimization set to 1 but gifsicle not found!
Warning: lossless_optimization set to 1 but pngquant not found!
Warning: lossless_optimization set to 1 but svgo not found!
Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.

System Information
------------------
Lychee Version (git):            master (376f8c7) - Data not in Cache
DB Version:                      4.2.2

composer install:                --no-dev
APP_ENV:                         production
APP_DEBUG:                       true

System:                          Linux
PHP Version:                     7.4
Max uploaded file size:          2048M
Max post size:                   2048M
MySQL Version:                   10.3.22-MariaDB

Imagick:                         1
Imagick Active:                  1
Imagick Version:                 1692
GD Version:                      2.3.1

Config Information
------------------
version:                         040202
check_for_updates:               1

Logging

Debugging is TRUE, so checking out the Laravel Log: The Log file has 1400 lines -- and the dates seem all wrong (Will have to check later how to fix that) Sorry, I don't know how to read the Log - any help is appreciated The latest flag is:

[2020-08-10 14:58:12] production.ERROR: SQLSTATE[HY000] [1044] Access denied for user 'USER'@'%' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 1044): SQLSTATE[HY000] [1044] Access denied for user 'USER'@'%' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') at /var/www/virtual/DOMAIN/Lychee/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671)
[stacktrace]

Browser and system

Firefox

ildyria commented 3 years ago

Hi, thank you for opening the issue. Indeed, it seems like it cannot connect to the database.

Did you truncate the Terminal Diagnostics ?

As per: https://lycheeorg.github.io/docs/faq.html#when-i-do-x-i-get-an-error-api-not-found-what-can-i-do

Open the dev modules of your browser (usually by pressing F12) and open the Network tab. Redo the action with Network tab open and look at the response of the last query (most likely a red line).

Can you check what the message is in your error 500? As you have enabled app_debug it should be displayed and not just a white page.

flow7 commented 3 years ago

Hi, thanks for the quick response, very much appreciated!

Terminal Diagnostics:

Yes, I truncated it, I had the impression, the rest wasn't as relevant anymore. Here we go:

Diagnostics
-----------
Warning: lossless_optimization set to 1 but cwebp not found!
Warning: lossless_optimization set to 1 but gifsicle not found!
Warning: lossless_optimization set to 1 but pngquant not found!
Warning: lossless_optimization set to 1 but svgo not found!
Warning: You may experience problems when uploading a large amount of photos. Take a look in the FAQ for details.

System Information
------------------
Lychee Version (git):            master (376f8c7) - Data not in Cache
DB Version:                      4.2.2

composer install:                --no-dev
APP_ENV:                         production
APP_DEBUG:                       true

System:                          Linux
PHP Version:                     7.4
Max uploaded file size:          2048M
Max post size:                   2048M
MySQL Version:                   10.3.22-MariaDB

Imagick:                         1
Imagick Active:                  1
Imagick Version:                 1692
GD Version:                      2.3.1

Config Information
------------------
version:                         040202
check_for_updates:               1
sorting_Photos_col:              takestamp
sorting_Photos_order:            ASC
sorting_Albums_col:              max_takestamp
sorting_Albums_order:            ASC
imagick:                         1
skip_duplicates:                 0
small_max_width:                 0
small_max_height:                360
medium_max_width:                1920
medium_max_height:               1080
lang:                            en
layout:                          1
image_overlay:                   1
image_overlay_type:              desc
default_license:                 reserved
compression_quality:             90
full_photo:                      1
delete_imported:                 0
Mod_Frame:                       1
Mod_Frame_refresh:               30
thumb_2x:                        1
small_2x:                        1
medium_2x:                       1
landing_page_enable:             0
landing_owner:                   Flo
landing_title:
landing_subtitle:
landing_facebook:
landing_flickr:
landing_twitter:
landing_instagram:
landing_youtube:
landing_background:
site_title:                      Lychee v4
site_copyright_enable:           1
site_copyright_begin:            2019
site_copyright_end:              2019
additional_footer_text:
display_social_in_gallery:       0
public_search:                   0
SL_enable:                       0
SL_for_admin:                    0
public_recent:                   0
recent_age:                      1
public_starred:                  0
downloadable:                    0
photos_wraparound:               1
map_display:                     1
zip64:                           1
map_display_public:              0
map_provider:                    OpenStreetMap.org
force_32bit_ids:                 0
map_include_subalbums:           1
update_check_every_days:         3
has_exiftool:                    0
share_button_visible:            0
import_via_symlink:              0
has_ffmpeg:                      1
location_decoding:               1
location_decoding_timeout:       30
location_show:                   1
location_show_public:            0
rss_enable:                      0
rss_recent_days:                 7
rss_max_items:                   100
prefer_available_xmp_metadata:   0
editor_enabled:                  1
lossless_optimization:           1
swipe_tolerance_x:               150
swipe_tolerance_y:               250
local_takestamp_video_formats:   .avi|.mov
log_max_num_line:                1000
unlock_password_photos_with_url_param: 0
nsfw_visible:                    1
nsfw_blur:                       0
nsfw_warning:                    0
nsfw_warning_admin:              0
map_display_direction:           1
album_subtitle_type:             oldstyle
upload_processing_limit:         4
public_photos_hidden:            1

Error Message

Honestly, it really is just a black screen - I have no idea why. Also, I couldn't find any more details regarding the error - see the screenshot from the Firefox inspector. Where else should I look for more details?

Screenshot 2021-04-02 at 17 02 13

Thanks

ildyria commented 3 years ago

the rest wasn't as relevant anymore

Actually, it was to make sure that you could connect to the SQL database in command line.

On that error 500, have a look at the Response tab on the right. You should see what the server returns (it should not be a blank page). This is where info are getting interesting with APP_DEBUG to true.

flow7 commented 3 years ago

Thanks, here is the Screenshot from the Response Tab - it actually shows an Error page by my provider. Screenshot 2021-04-02 at 17 27 07

According to the advice there, I've just activated the web logs and additionally found this log:

115.134.0.0 - - [02/Apr/2021:11:39:39 +0200] "GET / HTTP/2.0" 200 20612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:39 +0200] "GET /dist/Larapass.js HTTP/2.0" 304 0 "https://photos.DOMAIN.ORG/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:39 +0200] "GET /dist/user.css?1617356205 HTTP/2.0" 304 0 "https://photos.DOMAIN.ORG/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:39 +0200] "GET /dist/main.js?1617321840 HTTP/2.0" 304 0 "https://photos.DOMAIN.ORG/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:40 +0200] "POST /php/index.php HTTP/2.0" 500 1260 "https://photos.DOMAIN.ORG/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:41 +0200] "GET /dist/resources/livephotoskit.js.map HTTP/2.0" 500 1260 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
115.134.0.0 - - [02/Apr/2021:11:39:50 +0200] "GET /?controller=UserAjaxController&action=status HTTP/2.0" 200 28 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:87.0) Gecko/20100101 Firefox/87.0"
ildyria commented 3 years ago

Hummm this is not what an error 500 should look like; what I mean is that we have a dedicated way to handle them with Laravel, and providing the missing bits of information... 🤔

ildyria commented 3 years ago

So in regard to

[2020-08-10 14:58:12] production.ERROR: SQLSTATE[HY000] [1044] Access denied for user 'USER'@'%' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 1044): SQLSTATE[HY000] [1044] Access denied for user 'USER'@'%' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') at /var/www/virtual/DOMAIN/Lychee/vendor/laravel/framework/src/Illuminate/Database/Connection.php:671)
[stacktrace]

Knowing the code, my guess is as follows:

  1. Apache/Nginx is well configured in the sense that the redirection is working. You get a 500, not a 404. 👍
  2. Server tries to check if the files matches the database version and for this it needs to do a DB query.
  3. Server seems to not be able to connect to the database for an unknown reason. It does however recognize it is a MySQL one.
  4. As a result, there is only two possibilities I can guess:

    1. The dependencies when executing in command line are different from the dependencies when running on the server (PHP8 on server while PHP7.4 in command line?? Or missing dependencies like Mysql PDO etc..)
    2. The .env is not properly read when executed via server request.
ildyria commented 3 years ago

What this highlight however is that we need to have a try catch to fail gracefully in this case for the migration check DB query (which I am surprised we don't already do).

ildyria commented 3 years ago

Just having a look at the code, the migration is not the problem as you actually do access the / and do the JS query. Which means that there is a problem further down the line. 🤔

Route::post('/php/index.php', [SessionController::class, 'init']); // entry point if options are not initialized

This means that we go here: https://github.com/LycheeOrg/Lychee/blob/376f8c7c9c463816252319dcbdab2975d221ed8a/app/Http/Controllers/SessionController.php#L47-L58 then going down the code, the first Query is here: https://github.com/LycheeOrg/Lychee/blob/376f8c7c9c463816252319dcbdab2975d221ed8a/app/ModelFunctions/SessionFunctions.php#L116-L118

🤔

EDIT: Okay, my bad, the QUERY is for the MIGRATION table, so I am missing something here. 🤔

d7415 commented 3 years ago

Hummm this is not what an error 500 should look like;

Yeah, it looks like it's being eaten and replaced by the host.

4\. As a result, there is only two possibilities I can guess:

That matches my guesses!

What this highlight however is that we need to have a try catch to fail gracefully in this case for the migration check DB query (which I am surprised we don't already do).

Yeah, I remember similar coming up when we changed a query on the front page and it broke everything if the migration hadn't already run. Not quite the same here though, as the migration seems to have happened (well, not happened because it didn't need to).

flow7 commented 3 years ago

Sorry folks, you lost me there. I'm not that experienced with some of those aspects. However, if you have any suggestions, what I could try, let me know. Thanks so much too

nagmat84 commented 2 years ago

As there have been no new posts to this issue for the last 12 months and version 4.2.2 is not recent anymore, I am closing this issue. Feel free to open it again, if necessary.