janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
13.03k stars 1.39k forks source link

Internal Server Error - Editing Books - key error on language_name #839

Closed j-moran closed 5 years ago

j-moran commented 5 years ago

I have been getting errors when I attempt to edit a book. It keeps throwing the error below and reporting that there is an internal server error.

ERROR:flask.app:Exception on /admin/book/58 [GET]
Traceback (most recent call last):
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask\app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\jmoran\Downloads\calibre-web\cps\web.py", line 344, in decorated_view
return login_required(func)(*args, **kwargs)
  File "C:\Users\jmoran\Downloads\calibre-web\vendor\flask_login\utils.py", line 261, in decorated_view
return func(*args, **kwargs)
  File "C:\Users\jmoran\Downloads\calibre-web\cps\web.py", line 495, in inner
return f(*args, **kwargs)
  File "C:\Users\jmoran\Downloads\calibre-web\cps\web.py", line 3574, in edit_book
return render_edit_book(book_id)
  File "C:\Users\jmoran\Downloads\calibre-web\cps\web.py", line 3381, in render_edit_book
#book.languages[indx].language_name = language_table[get_locale()] 
   [book.languages[indx].lang_code]
KeyError: u'eng'

I was able to "fix" the issue by commenting out these two lines in web.py in the render_edit_book function.

#for indx in range(0, len(book.languages)):
    #book.languages[indx].language_name = language_table[get_locale()][book.languages[indx].lang_code]

Just wanted to see if there was something that I could have done to fix this issue other than mess with the code.

OzzieIsaacs commented 5 years ago

It's working for me. May I ask some questions? Do you use docker containers? (Which one Linuxserver, technosoft2000) If not, which operating system do you use? Which version of python are you using? Which user language you are using for Calibre-web? I guess the language of the book you try to replace is english, isn't it? Could you please try to replace the iso639.pickle file in folder: cps/translations/ with a new version from the githbub repro?

j-moran commented 5 years ago
  1. I do not use Docker containers, at least not for this instance.
  2. I am running Windows Server 2016 with Python 3.6.5 and 2.7.16.
  3. I am using English.
  4. Yes, the book is English.

I will try the iso639 file.

j-moran commented 5 years ago

Tried the latest iso639 file did not fix the issue. Still working by commenting out the lines.

OzzieIsaacs commented 5 years ago

Meanwhile I had a similar issue with the iso639 file under windows 10. In my case Windows wasn't able to read the file, because of problems with the line endings.

OzzieIsaacs commented 5 years ago

Are you familiar with python, and would it possible for you to do some debugging?

j-moran commented 5 years ago

I have some general knowledge, but nothing on a major level. I'll help however I can though.

OzzieIsaacs commented 5 years ago

Sorry for the long delay, I had no access to my comuter during the past 2 weeks. I decided that it might be easier if I add some debug outputs instead of letting you set up a whole debug setup. I created a branch "language error" could you please pull this one and start it (or just take the web.py file in the cps folder from that branch and replace your web.py file). Afterwards you should get some output lines on the console:

Using Pickle Length of table: 14 ru fr en nl\ zh_Hans_CN\ de\ it\ km\ hu\ es\ uk\ sv\ ja\ pl Could you please post this lines? (You should at least missing the 'en' line)