SABnzbd 1.0 gives "500 Internal Server Error"

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

Right after upgrading SABnzbd to 1.0, I get now get '500 Internal Server Error' when clicking some of the top-row menu links, such as Status or Config. Here's the full message:

Code: Select all

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.
Traceback (most recent call last):
  File "/usr/pbi/sabnzbd-amd64/share/sabnzbdplus/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/pbi/sabnzbd-amd64/share/sabnzbdplus/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/pbi/sabnzbd-amd64/share/sabnzbdplus/cherrypy/_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/site-packages/sabnzbd/interface.py", line 2455, in index
    header['folders'] = [xml_name(item) for item in sabnzbd.nzbqueue.scan_jobs(all=False, action=False)]
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/site-packages/sabnzbd/decorators.py", line 43, in call_func
    return func(*params, **kparams)
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/site-packages/sabnzbd/decorators.py", line 31, in newFunction
    return f(*args, **kw)
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/site-packages/sabnzbd/nzbqueue.py", line 1044, in scan_jobs
    return NzbQueue.do.scan_jobs(all, action)
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/site-packages/sabnzbd/nzbqueue.py", line 154, in scan_jobs
    if os.path.isdir(folder) and name not in registered and name not in IGNORED_FOLDERS:
  File "/usr/pbi/sabnzbd-amd64/lib/python2.7/genericpath.py", line 41, in isdir
    st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 28-31: ordinal not in range(128)

I'm running FreeNAS-9.3-STABLE-201602031011.
So... what did I do wrong?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by shypike »

Your file system probably doesn't match your LANG settings.
See this complicated discussion: https://github.com/sabnzbd/sabnzbd/issues/543
User avatar
sander
Release Testers
Release Testers
Posts: 8829
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by sander »

Complicated discussion indeed ... but maybe the workaround is easy:

Do you run SABnzbd from the command line? Or from a daemon / service?
Which OS
Post the output of

Code: Select all

locale
and

Code: Select all

locale -a
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

I'm running SABnzbd in a jail on my FreeNAS system. Version 0.7.x (and previous versions before that) all ran fine. It's the upgrade to 1.0 that broke it. SABnzbd runs and downloads fine; it's just the config/menu links that appear to be broken.

locale reports:

Code: Select all

root@sabnzbd_1:/ # locale                                                                                                           
LANG=en_US.UTF-8                                                                                                                    
LC_CTYPE="en_US.UTF-8"                                                                                                              
LC_COLLATE="en_US.UTF-8"                                                                                                            
LC_TIME="en_US.UTF-8"                                                                                                               
LC_NUMERIC="en_US.UTF-8"                                                                                                            
LC_MONETARY="en_US.UTF-8"                                                                                                           
LC_MESSAGES="en_US.UTF-8"                                                                                                           
LC_ALL=                                                                                                                             
root@sabnzbd_1:/ # 
User avatar
sander
Release Testers
Release Testers
Posts: 8829
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by sander »

And how about my other questions?


Furthermore: What is the output of:

Code: Select all

python -c "import locale; print locale.getpreferredencoding()"
Do you think you can find and edit Python file SABnzbd.py (or/usr/bin/sabnzbdplus, depending on your system), and add one line? Most safe way: download SAB 1.0.1 in a separate directory, and use that.

If so: At line 1372 in SABnzbd.py, add the line with 'SJ: preferred encoding':

Code: Select all

    logging.info("SSL actually supported protocols %s", str(sabnzbd.utils.sslinfo.ssl_protocols()))

    logging.info("SJ: preferred encoding is %s", locale.getpreferredencoding() )

    cherrylogtoscreen = False
sabnzbd.log will then show something like this:

Code: Select all

2016-04-27 07:26:06,519::INFO::[SABnzbd:1370] SSL actually supported protocols ['t1', 'v23', 'v3']
2016-04-27 07:26:06,519::INFO::[SABnzbd:1372] SJ: preferred encoding is UTF-8
2016-04-27 07:26:06,525::INFO::[SABnzbd:1519] Starting web-interface on 0.0.0.0:9090
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

Oddly, the file at /usr/local/bin/SABnzbd.py isn't ASCII text. Correct me if I'm wrong, but aren't python files supposed to be human readable? I can't open it with any of my usual text editors. Changing encoding (UTF-7, UTF-8, etc.) doesn't help, either.

Edit: Never mind; i was looking in the wrong directory.
Last edited by RoadHazard on April 28th, 2016, 12:00 pm, edited 1 time in total.
User avatar
sander
Release Testers
Release Testers
Posts: 8829
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by sander »

RoadHazard wrote:Oddly, the file at /usr/local/bin/SABnzbd.py isn't ASCII text. Correct me if I'm wrong, but aren't python files supposed to be human readable?
You're correct: .py files should be text, and human readable.
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

Well, I downloaded a fresh SABnzbd.py from github, added the line you suggested, and replaced my weirdly encoded /usr/pbi/sabnzbd/amd-64/.sbin/SABnzbd.py. FYI, the existing .py file was 11440 bytes while the clean ASCII replacement is 70442 bytes. Restarted SABnzbd and nothing appears to change. Evidently python had no trouble reading the oddly encoded original file. Either that, or I'm looking in the wrong place.

Edit: Never mind. There are two copies of SABnzbd.py, one in /bin and one in /.sbin. Naturally, I was looking at the wrong one.

Code: Select all

python -c "import locale; print locale.getpreferredencoding()"
This reports UTF-8.

I do notice, however, that I can "hack" the menu links to avoid the '500 Internal Server Error" message. For example, hovering over the 'Config' menu item links to http://<IP address>:8080/sabnzbd/config/ which fails. But if I append /general or /folders to that URL, it works. Does that suggest anything?
User avatar
sander
Release Testers
Release Testers
Posts: 8829
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by sander »

Did you add my line to your actual/real SABnzbd.py, restarted SABnzbd and then checked sabnzbd.log? There should be a line with "SJ: preferred encoding is". Please paste that line here.
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

sander wrote:Did you add my line to your actual/real SABnzbd.py, restarted SABnzbd and then checked sabnzbd.log? There should be a line with "SJ: preferred encoding is". Please paste that line here.
Here it is:

Code: Select all

2016-04-28 12:00:00,949::INFO::[SABnzbd:1372] SSL potentially supported protocols ['SSLv2', 'SSLv23', 'SSLv3', 'TLSv1', 'TLSv1_1', 'TLSv1_2']
2016-04-28 12:00:00,949::INFO::[SABnzbd:1373] SSL actually supported protocols ['t12', 't11', 't1', 'v23', 'v3', 'v2']
2016-04-28 12:00:00,949::INFO::[SABnzbd:1374] SJ: preferred encoding is US-ASCII
2016-04-28 12:00:00,951::INFO::[SABnzbd:1521] Starting web-interface on 0.0.0.0:8080
User avatar
sander
Release Testers
Release Testers
Posts: 8829
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by sander »

Tada:

Code: Select all

2016-04-28 12:00:00,949::INFO::[SABnzbd:1374] SJ: preferred encoding is US-ASCII
... so, no UTF-8 in your preferred encoding with a runnin SABnzbd. That is the problem. Exactly as described in the lengthy thread on github https://github.com/sabnzbd/sabnzbd/issues/543

So ... back to what I asked in my first post:

"Do you run SABnzbd from the command line? Or from a daemon / service?"

You said "in a jail". Hmmm ... that does not fully answer my question.

Reason of my question: if from the command line, on Linux, you can solve it like this:

Code: Select all

LANG=en_US.utf8  /path/to/SABnzbd.py
I think it's the same on FreeBSD ... Can you try?

EDIT:

My guess is SAB in a jail is started as a daemon /service. If so, I can't help you much further, but check out https://forums.sabnzbd.org/viewtopic.ph ... 60#p105493 (FreeBSD user with same problem, which is the source for the github issue report).

But best is probably to get help on the FreeNAS forum, for example in the thread you started: https://forums.freenas.org/index.php?th ... ror.43004/

Your question there should be: how can I change the LANG setting to "LANG=en_US.utf8" of the running SABnzbd jail on FreeNAS. I think this can be done in the startup (RC?) script.
RoadHazard
Newbie
Newbie
Posts: 10
Joined: April 26th, 2016, 12:09 pm

Re: SABnzbd 1.0 gives "500 Internal Server Error"

Post by RoadHazard »

Thanks for all the help. I finally gave up and reinstalled 1.0.1 from scratch in a new FreeNAS jail. It works perfectly, of course, so we'll never know why my particular system had a problem.
Post Reply