linuxserver/docker-lazylibrarian

500 Internal server error on /config caused by apprise

Closed this issue ยท 11 comments

Whenever I visit the /config page I see this in my browser tab:

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/app/lazylibrarian/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/app/lazylibrarian/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/app/lazylibrarian/cherrypy/_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/app/lazylibrarian/lazylibrarian/webServe.py", line 1030, in config
    apprise_list = lazylibrarian.notifiers.apprise_notify.Apprise_Notifier.notify_types()
  File "/app/lazylibrarian/lazylibrarian/notifiers/apprise_notify.py", line 98, in notify_types
    apobj = Apprise()
  File "/usr/lib/python2.7/site-packages/apprise/Apprise.py", line 78, in __init__
    self.locale = AppriseLocale()
  File "/usr/lib/python2.7/site-packages/apprise/AppriseLocale.py", line 111, in __init__
    self.lang = AppriseLocale.detect_language(language)
  File "/usr/lib/python2.7/site-packages/apprise/AppriseLocale.py", line 207, in detect_language
    return lang[0:2].lower()
TypeError: 'NoneType' object has no attribute '__getitem__'

I'm running on a Linux host machine, starting like so:

docker create \
  --name=lazy-librarian \
  -e PUID=1001 \
  -e PGID=1001 \
  -e TZ=Europe/Amsterdam \
  -p 5299:5299 \
  -v /local/config/lazy-librarian:/config \
  -v /local/storage/downloads/library:/downloads \
  -v /local/storage/library:/books \
  linuxserver/lazylibrarian

/local/storage is a symlink to /mnt/storage which is a btrfs pool.

The issue persist even without any volume mounts.

Docker logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...
usermod: no changes

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/


Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1001
User gid:    1001
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
[cont-init.d] 30-config: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Lazylibrarian (pid 222) is starting up...
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:initialize:700 : Log (Rotating) Level set to [1]- Log Directory is [/config/log] - Config level is [1]
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:initialize:706 : Screen Log set to INFO
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:config_read:1064 : Config file loaded
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:initialize:770 : Database is version 53, integrity check: ok
04-Jun-2019 20:04:43 - INFO :: MAIN : dbupgrade.py:check_db:489 : Database check found 0 errors
04-Jun-2019 20:04:43 - INFO :: MAIN : common.py:logHeader:1234 : Checking TLS version, you can ignore any "InsecureRequestWarning" message
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
04-Jun-2019 20:04:43 - WARNING :: MAIN : __init__.py:initialize:796 : magic: missing
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:build_genres:1594 : Loaded genres from /app/lazylibrarian/example.genres.json
04-Jun-2019 20:04:43 - INFO :: MAIN : __init__.py:build_bookstrap_themes:1579 : Bookstrap found 16 themes
04-Jun-2019 20:04:44 - INFO :: MAIN : LazyLibrarian.py:main:247 : Apprise library (0.7.7) installed
04-Jun-2019 20:04:44 - INFO :: MAIN : LazyLibrarian.py:main:265 : Starting LazyLibrarian on port: 5299, webroot ""
04-Jun-2019 20:04:44 - INFO :: MAIN : webStart.py:initialize:66 : Starting LazyLibrarian web server on http://0.0.0.0:5299/

If I do a clean clone inside /app/lazylibrarian, the issue persists. pip freeze shows apprise==0.7.7.

If I do a test on the host machine inside a virtualenv with apprise==0.7.7 installed and a git clone from master; it actually works. Ideas as to what could cause this issue ?

I believe this issue is my fault. apprise v0.7.7 introduced i18n (localization strings) and i thought I had covered all aspects of how it could fail through unit-tests. But your logs clearly indicate that this isn't the case.

I will open a ticket and fix this; the workaround should be to simply emulate any kind of general localization environment.. either with a LANGUAGE=en_US, , LANG=en_CA, LC_ALL=C, etc. I'm not a docker expert, but perhaps this might work:

# add LANG= workaround
docker create \
  --name=lazy-librarian \
  -e PUID=1001 \
  -e PGID=1001 \
  -e TZ=Europe/Amsterdam \
  -e LANG=en_US \
  -p 5299:5299 \
  -v /local/config/lazy-librarian:/config \
  -v /local/storage/downloads/library:/downloads \
  -v /local/storage/library:/books \
  linuxserver/lazylibrarian

These variables would be present in a virtual env which is why that works for you. When a fix is in place, that extra -e tag shouldn't be required.

Passing -e LANG=.. indeed solves it, thanks!

CHBMB commented

OK, I'll leave this issue open for now until it's fixed upstream. @caronc Thanks for the fix. Slightly curious how you managed to come upon this repository, but mighty glad you did.

Slightly curious how you managed to come upon this repository

@CHBMB. Hah, as a small notification library guy, i don't get the same exposure to complaints/issues as front facing systems like yours do. I'm not sure if i should be thankful or remorseful that you get the blame! heh. ๐Ÿ˜‰

Regardless, as a result I don't always get the issue raised upstream on my end to fix/improve things if I don't attempt to be proactive about it and seek out the complaints on my own. Thankfully GitHub's search engine is amazing and allows me to search for my system name and specifically list issues. I found this thread in a search I made today ๐Ÿ™‚

Thank you for not minding me creep this issue here and thank you for using apprise! It's threads like this that allow me to make my system just a wee bit better! ๐Ÿ‘

This helped. I was having the same issue

CHBMB commented

@caronc Like I said, mighty glad you stumbled across this!

Help with anything always appreciated!

Due to the severity of this (well, at least from my perspective), and the fact that anyone using apprise in a docker container might be kind of hitting this annoyance, I did another release. It's also available on PyPi; so users of this container can definitely fix their problem with a pip update:

pip install apprise --upgrade

Alternatively the workaround identified above is definitely a valid solution; the only thing this last minute release does is just not crash if LANG= isn't present.

Maybe someone can try this out for me? Maybe drop the -e LANG= entry for full clarification? Then you can probably close this ticket otherwise. I'm pretty sure my new unit-tests cover this case so we should be good.

CHBMB commented

@caronc I'll trigger a new release, seeing as linuxserver/lazylibrarian:latest is broken anyway

CHBMB commented

@cpoppema Can you confirm linuxserver/lazylibrarian:latest is now working please?

@CHBMB Looks like it works now ๐Ÿ‘ Thanks for the update.

CHBMB commented

@caronc Looks like everything is ship shape again, Thanks again!