Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP500 on uploads #3261

Open
Ting3l opened this issue Dec 16, 2024 · 2 comments
Open

HTTP500 on uploads #3261

Ting3l opened this issue Dec 16, 2024 · 2 comments
Labels

Comments

@Ting3l
Copy link

Ting3l commented Dec 16, 2024

Description

I get "HTTP500" on every try to upload a book.
I tried resetting permissions and restarting the container and even the host.
Looking into /books, calibe is able to create the initial dir for the epub, but can't send the epub itself there.

Steps to reproduce the behavior:
Drag&Drop a book or select it via the file-chooser and upload.

Logfile

[2024-12-16 15:07:14,897]  WARN {py.warnings:110} /app/calibre-web/cps/editbooks.py:1405: SAWarning: Object of type <Books> not in session, add operation along 'Authors.books' won't proceed (This warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation.)
  db_element = db_session.query(db_object).filter((func.lower(db_filter).ilike(add_element))).all()
[2024-12-16 15:07:14,914]  WARN {py.warnings:110} /app/calibre-web/cps/editbooks.py:1405: SAWarning: Object of type <Books> not in session, add operation along 'Languages.books' won't proceed (This warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation.)
  db_element = db_session.query(db_object).filter((func.lower(db_filter).ilike(add_element))).all()
[2024-12-16 15:07:14,920]  WARN {py.warnings:110} /app/calibre-web/cps/editbooks.py:1405: SAWarning: Object of type <Books> not in session, add operation along 'Tags.books' won't proceed (This warning originated from the Session 'autoflush' process, which was invoked automatically in response to a user-initiated operation.)
  db_element = db_session.query(db_object).filter((func.lower(db_filter).ilike(add_element))).all()
[2024-12-16 15:07:14,981] ERROR {cps.helper:557} Rename title from /tmp/calibre_web/535d88ad4e9b9f056e6bd9039711182a to /books/Taddl/What The Fact_ Vollig unnutzes Wissen (1865) failed with error: [Errno 13] Permission denied: '/books/Taddl/What The Fact_ Vollig unnutzes Wissen (1865)'
[2024-12-16 15:07:14,981] ERROR {cps:838} Exception on /upload [POST]
Traceback (most recent call last):
  File "/lsiopy/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/usermanagement.py", line 97, in decorated_view
    return login_required(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/cw_login/utils.py", line 296, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 60, in inner
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/editbooks.py", line 138, in upload
    error = helper.update_dir_structure(book_id,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/helper.py", line 714, in update_dir_structure
    return update_dir_structure_file(book_id,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/calibre-web/cps/helper.py", line 473, in update_dir_structure_file
    rename_all_files_on_change(local_book, new_path, new_path, all_new_name)
  File "/app/calibre-web/cps/helper.py", line 400, in rename_all_files_on_change
    os.makedirs(new_path)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/books/Taddl/What The Fact_ Vollig unnutzes Wissen (1865)'

Screenshots

grafik

Environment

  • OS: Debian GNU/Linux 11 (bullseye)
  • Python version: 3.9.2
  • Calibre-Web version: 0.6.24
  • Docker container: LinuxServer
  • Browser: Any
@OzzieIsaacs
Copy link
Collaborator

You are missing write permissions on the folder '/books/Taddl/What The Fact_ Vollig unnutzes Wissen (1865)', don't ask me why and how. This is a typical problem from docker users. I don't support the docker container. You could ask for help on the discord channel, there is a user named "driz" who could help

OzzieIsaacs added a commit that referenced this issue Dec 21, 2024
OzzieIsaacs added a commit that referenced this issue Dec 21, 2024
@ajn142
Copy link

ajn142 commented Dec 28, 2024

I experienced this same issue and was able to resolve it. I attempted switching to the nightly container to get the fixes added since the last comment in this issue. The additional error handling warned me that the book was likely already uploaded (but it wasn’t). Reattempting upload still generated a 500 error.

I went into the container via docker exec -it calibre-web bash and checked the owner of the author directories in /books ls -l /books/ and there were about 5-10 from recent uploads that said they belonged to root, including the author directory for the latest book I was uploading. The majority of directories belonged to abc, which per top was the user running python3 inside the container. A quick chown -R abc:abc /books/ and everything is working well.

My best guess as to cause is that under some previous container version, python3 was running as root, which caused no issues at the time since root has permissions to everything, but caused things to break on upgrade when they went back to using the abc user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants