calibre-web icon indicating copy to clipboard operation
calibre-web copied to clipboard

500 error when uploading epub ebook

Open chrisheil opened this issue 2 years ago • 2 comments

Describe the bug/problem When I attempt to upload a specific ebook the entire page is rendered white with a stack trace error message. On refresh the ebook appears, but it has no metadata and cannot be opened in the web reader.

It seems to be a specific ebook (in an epub format) and all others I have tried have worked without issue.

To Reproduce Steps to reproduce the behavior:

  1. On the home page click the Upload button
  2. Select ebook to upload
  3. See error

Logfile

Relevant entry from calibre-web.log, this is also what gets displayed on the site.

[2023-12-31 11:28:28,419] ERROR {cps:1414} Exception on /upload [POST]
Traceback (most recent call last):
  File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/lsiopy/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/app/calibre-web/cps/usermanagement.py", line 35, in decorated_view
    return login_required(func)(*args, **kwargs)
  File "/lsiopy/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/app/calibre-web/cps/editbooks.py", line 62, in inner
    return f(*args, **kwargs)
  File "/app/calibre-web/cps/editbooks.py", line 260, in upload
    modify_date |= edit_book_comments(Markup(meta.description).unescape(), db_book)
  File "/app/calibre-web/cps/editbooks.py", line 995, in edit_book_comments
    comments = clean_html(comments)
  File "src/lxml/html/clean.py", line 561, in lxml.html.clean.Cleaner.clean_html
  File "/lsiopy/lib/python3.10/site-packages/lxml/html/__init__.py", line 873, in fromstring
    doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
  File "/lsiopy/lib/python3.10/site-packages/lxml/html/__init__.py", line 761, in document_fromstring
    raise etree.ParserError(
lxml.etree.ParserError: Document is empty

Expected behavior

The ebook to be uploaded and readable.

Screenshots

Same as log entry above

Environment (please complete the following information):

  • OS: TrueNas Scale
  • Python version: Not sure, it is included in the Dockerfile I assume
  • Calibre-Web version: 0.6.21
  • Docker container: LinuxServer:0.6.21 via the TrueCharts app
  • Special Hardware: Intel based Desktop
  • Browser: Firefox 121.0

Additional context Google Play Books had no issue uploading and reading this book, so I don't suspect it is corrupted. I can provide the ebook upon request to help troubleshoot what the issue is. I don't want to publicly upload copyrighted materials though which is why I am not attaching to the initial ticket.

chrisheil avatar Dec 31 '23 18:12 chrisheil

Yes it's very likely a bug. To solve it definitely, it would be good for me to have the book. If it's an epub book, the content.opf file would be sufficient (open the epub file as zip and then you will normally see the file in the root folder). Preferably send me the file to my email address visible on my github profile page

OzzieIsaacs avatar Dec 31 '23 18:12 OzzieIsaacs

I just sent an email with the file. It was under the OEBPS folder once I converted it into a zip.

Thank you for taking a look and I will be happy to provide more information if needed

chrisheil avatar Dec 31 '23 19:12 chrisheil