Skip to content

[BUG] 500 Internal server error, Python errors when trying to search or access language settings #348

@pmsobrado

Description

@pmsobrado

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Trying to access search function or language settings causes internal server error 500 with python errors.

Expected Behavior

Search function and language settings should be accessed without errors.

Steps To Reproduce

Just create a new container and check. I'm using Container manager app on a Synology home server.

Environment

- OS: Synology
- How docker service was installed: I just created the container with the Synology Container manager app. I tried on two different Synology servers.

CPU architecture

x86-64

Docker creation

This was done internally, I did not ran any command.

Container logs

The server encountered an internal error and was unable to complete your request. There is an error in the application.
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/web.py", line 1111, in language_overview
languages = calibre_db.speaking_language(reverse_order=not order_no, with_count=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/calibre-web/cps/db.py", line 996, in speaking_language
languages = self.session.query(Languages, func.count('books_languages_link.book'))\
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'query'






Calibre-Web
500 Internal Server Error
The server encountered an internal error and was unable to complete your request. There is an error in the application.
Traceback (most recent call last):
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context
self.dialect.do_execute(
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
cursor.execute(statement, parameters)
sqlite3.DatabaseError: database disk image is malformed
The above exception was the direct cause of the following exception:
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/web.py", line 822, in books_list
return render_books_list(data, sort_param, book_id, page)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/calibre-web/cps/web.py", line 412, in render_books_list
return render_search_results(term, offset, order, config.config_books_per_page)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/calibre-web/cps/search.py", line 408, in render_search_results
entries, result_count, pagination = calibre_db.get_search_results(term,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/calibre-web/cps/db.py", line 976, in get_search_results
result = self.search_query(term, config, *join).order_by(*order).all()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2704, in all
return self._iter().all() # type: ignore
^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2857, in _iter
result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2365, in execute
return self._execute_internal(
^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2251, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/orm/context.py", line 306, in orm_execute_statement
result = conn.execute(
^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1415, in execute
return meth(
^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 523, in _execute_on_connection
return connection._execute_clauseelement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1637, in _execute_clauseelement
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context
return self._exec_single_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1982, in _exec_single_context
self._handle_dbapi_exception(
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2351, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context
self.dialect.do_execute(
File "/lsiopy/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: SELECT books.id AS books_id, books.title AS books_title, books.sort AS books_sort, books.author_sort AS books_author_sort, books.timestamp AS books_timestamp, books.pubdate AS books_pubdate, books.series_index AS books_series_index, books.last_modified AS books_last_modified, books.path AS books_path, books.has_cover AS books_has_cover, books.uuid AS books_uuid, books.isbn AS books_isbn, books.flags AS books_flags, archived_book.is_archived AS archived_book_is_archived, book_read_link.read_status AS book_read_link_read_status
FROM books LEFT OUTER JOIN book_read_link ON book_read_link.user_id = ? AND book_read_link.book_id = books.id LEFT OUTER JOIN archived_book ON books.id = archived_book.book_id AND archived_book.user_id = ? LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book LEFT OUTER JOIN series ON series.id = books_series_link.series
WHERE 1 = 1 AND ((EXISTS (SELECT 1
FROM tags, books_tags_link
WHERE books.id = books_tags_link.book AND tags.id = books_tags_link.tag AND lower(lower(tags.name)) LIKE lower(?))) OR (EXISTS (SELECT 1
FROM series, books_series_link
WHERE books.id = books_series_link.book AND series.id = books_series_link.series AND lower(lower(series.name)) LIKE lower(?))) OR (EXISTS (SELECT 1
FROM authors, books_authors_link
WHERE books.id = books_authors_link.book AND authors.id = books_authors_link.author AND (EXISTS (SELECT 1
FROM authors, books_authors_link
WHERE books.id = books_authors_link.book AND authors.id = books_authors_link.author AND lower(lower(authors.name)) LIKE lower(?))))) OR (EXISTS (SELECT 1
FROM publishers, books_publishers_link
WHERE books.id = books_publishers_link.book AND publishers.id = books_publishers_link.publisher AND lower(lower(publishers.name)) LIKE lower(?))) OR lower(lower(books.title)) LIKE lower(?) OR (EXISTS (SELECT 1
FROM custom_column_1, books_custom_column_1_link
WHERE books.id = books_custom_column_1_link.book AND custom_column_1.id = books_custom_column_1_link.value AND lower(lower(custom_column_1.value)) LIKE lower(?))) OR (EXISTS (SELECT 1
FROM custom_column_6, books_custom_column_6_link
WHERE books.id = books_custom_column_6_link.book AND custom_column_6.id = books_custom_column_6_link.value AND lower(lower(custom_column_6.value)) LIKE lower(?))) OR (EXISTS (SELECT 1
FROM custom_column_9, books_custom_column_9_link
WHERE books.id = books_custom_column_9_link.book AND custom_column_9.id = books_custom_column_9_link.value AND lower(lower(custom_column_9.value)) LIKE lower(?)))) ORDER BY books.timestamp DESC]
[parameters: (1, 1, '%rechicero%', '%rechicero%', '%rechicero%', '%rechicero%', '%rechicero%', '%rechicero%', '%rechicero%', '%rechicero%')]
(Background on this error at: https://sqlalche.me/e/20/4xp6)

I've created an issue on calibre-web GH as well: janeczku/calibre-web#3414

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions