# Buggy code
def update_view_configuration():
    reboot_required = False
    to_save = request.form.to_dict()

    _config_string = lambda x: config.set_from_dictionary(
        to_save, x, lambda y: y.strip() if y else y
    )
    _config_int = lambda x: config.set_from_dictionary(to_save, x, int)

    _config_string("config_calibre_web_title")
    _config_string("config_columns_to_ignore")
    # _config_string("config_mature_content_tags")
    reboot_required |= _config_string("config_title_regex")

    _config_int("config_read_column")
    _config_int("config_theme")
    _config_int("config_random_books")
    _config_int("config_books_per_page")
    _config_int("config_authors_max")
    _config_int("config_restricted_column")

    if config.config_google_drive_watch_changes_response:
        config.config_google_drive_watch_changes_response = json.dumps(
            config.config_google_drive_watch_changes_response
        )

    config.config_default_role = constants.selected_roles(to_save)
    config.config_default_role &= ~constants.ROLE_ANONYMOUS

    config.config_default_show = sum(
        int(k[5:]) for k in to_save if k.startswith("show_")
    )
    if "Show_detail_random" in to_save:
        config.config_default_show |= constants.DETAIL_RANDOM

    config.save()
    flash(_("Calibre-Web configuration updated"), category="success")
    before_request()
    if reboot_required:
        db.dispose()
        ub.dispose()
        web_server.stop(True)

    return view_configuration()


# Traceback (sqlite3.InterfaceError)
[services.d] starting services
[services.d] done.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 272, in decorated_view
return func(*args, **kwargs)
File "/app/calibre-web/cps/web.py", line 213, in inner
return f(*args, **kwargs)
File "/app/calibre-web/cps/admin.py", line 142, in configuration
return _configuration_update_helper()
File "/app/calibre-web/cps/admin.py", line 673, in _configuration_update_helper
config.save()
File "/app/calibre-web/cps/config_sql.py", line 289, in save
self._session.merge(s)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2117, in merge
self._autoflush()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1602, in _autoflush
util.raise_(e, with_traceback=sys.exc_info()[2])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1591, in _autoflush
self.flush()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2496, in flush
self._flush(objects)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2637, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2597, in _flush
flush_context.execute()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
rec.execute(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
uow,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/persistence.py", line 236, in save_obj
update,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/persistence.py", line 995, in _emit_update_statements
statement, multiparams
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 984, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1103, in _execute_clauseelement
distilled_params,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1288, in _execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1482, in _handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from_=e
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 590, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.InterfaceError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 968, in handle_one_response
self.run_application()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 915, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/app/calibre-web/cps/reverseproxy.py", line 80, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1879, in handle_exception
server_error = handler(server_error)
File "/app/calibre-web/cps/web.py", line 107, in internal_error
instance=config.config_calibre_web_title
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/local/lib/python3.6/dist-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.6/dist-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.6/dist-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/app/calibre-web/cps/templates/http_error.html", line 2, in top-level template code
<html class="http-error" lang="{{ g.user.locale }}">
File "/usr/local/lib/python3.6/dist-packages/jinja2/environment.py", line 471, in getattr
return getattr(obj, attribute)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/attributes.py", line 286, in __get__
return self.impl.get(instance_state(instance), dict_)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/attributes.py", line 717, in get
value = state._load_expired(state, passive)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/state.py", line 652, in _load_expired
self.manager.deferred_scalar_loader(self, toload)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/loading.py", line 1012, in load_scalar_attributes
only_load_props=attribute_names,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/loading.py", line 207, in load_on_ident
identity_token=identity_token,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/loading.py", line 287, in load_on_pk_identity
return q.one()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3360, in one
ret = self.one_or_none()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3329, in one_or_none
ret = list(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-05-12T06:43:20Z {'REMOTE_ADDR': '::ffff:192.168.2.7', 'REMOTE_PORT': '51876', 'HTTP_HOST': 'calibre.net-slum.org', (hidden keys: 38)} failed with InvalidRequestError

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2242, in preprocess_request
rv = func()
File "/app/calibre-web/cps/web.py", line 293, in before_request
or_(ub.Shelf.is_public == 1, ub.Shelf.user_id == current_user.id)).order_by(ub.Shelf.name).all()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 968, in handle_one_response
self.run_application()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 915, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/app/calibre-web/cps/reverseproxy.py", line 80, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1879, in handle_exception
server_error = handler(server_error)
File "/app/calibre-web/cps/web.py", line 107, in internal_error
instance=config.config_calibre_web_title
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 136, in render_template
ctx.app.update_template_context(context)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 838, in update_template_context
context.update(func())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 379, in _user_context_processor
return dict(current_user=_get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-05-12T06:43:20Z {'REMOTE_ADDR': '::ffff:192.168.2.7', 'REMOTE_PORT': '51860', 'HTTP_HOST': 'calibre.net-slum.org', (hidden keys: 32)} failed with InvalidRequestError

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2242, in preprocess_request
rv = func()
File "/app/calibre-web/cps/web.py", line 293, in before_request
or_(ub.Shelf.is_public == 1, ub.Shelf.user_id == current_user.id)).order_by(ub.Shelf.name).all()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 968, in handle_one_response
self.run_application()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 915, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/app/calibre-web/cps/reverseproxy.py", line 80, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1879, in handle_exception
server_error = handler(server_error)
File "/app/calibre-web/cps/web.py", line 107, in internal_error
instance=config.config_calibre_web_title
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 136, in render_template
ctx.app.update_template_context(context)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 838, in update_template_context
context.update(func())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 379, in _user_context_processor
return dict(current_user=_get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-05-12T06:43:24Z {'REMOTE_ADDR': '::ffff:192.168.2.7', 'REMOTE_PORT': '51880', 'HTTP_HOST': 'calibre.net-slum.org', (hidden keys: 33)} failed with InvalidRequestError

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2242, in preprocess_request
rv = func()
File "/app/calibre-web/cps/web.py", line 293, in before_request
or_(ub.Shelf.is_public == 1, ub.Shelf.user_id == current_user.id)).order_by(ub.Shelf.name).all()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 968, in handle_one_response
self.run_application()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 915, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/app/calibre-web/cps/reverseproxy.py", line 80, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1879, in handle_exception
server_error = handler(server_error)
File "/app/calibre-web/cps/web.py", line 107, in internal_error
instance=config.config_calibre_web_title
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 136, in render_template
ctx.app.update_template_context(context)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 838, in update_template_context
context.update(func())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 379, in _user_context_processor
return dict(current_user=_get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-05-12T06:43:24Z {'REMOTE_ADDR': '::ffff:192.168.2.7', 'REMOTE_PORT': '51870', 'HTTP_HOST': 'calibre.net-slum.org', (hidden keys: 32)} failed with InvalidRequestError

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2242, in preprocess_request
rv = func()
File "/app/calibre-web/cps/web.py", line 293, in before_request
or_(ub.Shelf.is_public == 1, ub.Shelf.user_id == current_user.id)).order_by(ub.Shelf.name).all()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 968, in handle_one_response
self.run_application()
File "/usr/local/lib/python3.6/dist-packages/gevent/pywsgi.py", line 915, in run_application
self.result = self.application(self.environ, self.start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/app/calibre-web/cps/reverseproxy.py", line 80, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1879, in handle_exception
server_error = handler(server_error)
File "/app/calibre-web/cps/web.py", line 107, in internal_error
instance=config.config_calibre_web_title
File "/usr/local/lib/python3.6/dist-packages/flask/templating.py", line 136, in render_template
ctx.app.update_template_context(context)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 838, in update_template_context
context.update(func())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 379, in _user_context_processor
return dict(current_user=_get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-05-12T06:43:26Z {'REMOTE_ADDR': '::ffff:192.168.2.7', 'REMOTE_PORT': '51862', 'HTTP_HOST': 'calibre.net-slum.org', (hidden keys: 33)} failed with InvalidRequestError

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1948, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2242, in preprocess_request
rv = func()
File "/app/calibre-web/cps/web.py", line 293, in before_request
or_(ub.Shelf.is_public == 1, ub.Shelf.user_id == current_user.id)).order_by(ub.Shelf.name).all()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 26, in <lambda>
current_user = LocalProxy(lambda: _get_user())
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 346, in _get_user
current_app.login_manager._load_user()
File "/usr/local/lib/python3.6/dist-packages/flask_login/login_manager.py", line 318, in _load_user
user = self._user_callback(user_id)
File "/app/calibre-web/cps/web.py", line 138, in load_user
return ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3300, in first
ret = list(self[0:1])
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3078, in __getitem__
return list(res)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3405, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3427, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3442, in _get_bind_args
mapper=self._bind_mapper(), clause=querycontext.statement, **kw
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/query.py", line 3420, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1133, in connection
execution_options=execution_options,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
engine, execution_options
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
self._assert_active()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 295, in _assert_active
code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type.
[SQL: UPDATE settings SET config_google_drive_folder=?, config_google_drive_watch_changes_response=? WHERE settings.id = ?]
[parameters: ('Google Drive Folder Name I Am Not Using', {'kind': 'api#channel', 'id': 'idnumberhere', 'resourceId': 'resourceidhere', 'resourceUri': 'https://www.googlea ... (162 characters truncated) ... se&amp;maxResults=100&amp;supportsAllDrives=false&amp;supportsTeamDrives=false&amp;alt=json', 'token': 'target=calibreweb-watch_files', 'expiration': '1589870595000'}, 1)]
(Background on this error at: http://sqlalche.me/e/rvf5) (Background on this error at: http://sqlalche.me/e/7s2a)

# Fixed code
def update_view_configuration():
    reboot_required = False
    to_save = request.form.to_dict()

    _config_string = lambda x: config.set_from_dictionary(
        to_save, x, lambda y: y.strip() if y else y
    )
    _config_int = lambda x: config.set_from_dictionary(to_save, x, int)

    _config_string("config_calibre_web_title")
    _config_string("config_columns_to_ignore")
    # _config_string("config_mature_content_tags")
    reboot_required |= _config_string("config_title_regex")

    _config_int("config_read_column")
    _config_int("config_theme")
    _config_int("config_random_books")
    _config_int("config_books_per_page")
    _config_int("config_authors_max")
    _config_int("config_restricted_column")

    config.config_default_role = constants.selected_roles(to_save)
    config.config_default_role &= ~constants.ROLE_ANONYMOUS

    config.config_default_show = sum(
        int(k[5:]) for k in to_save if k.startswith("show_")
    )
    if "Show_detail_random" in to_save:
        config.config_default_show |= constants.DETAIL_RANDOM

    config.save()
    flash(_("Calibre-Web configuration updated"), category="success")
    before_request()
    if reboot_required:
        db.dispose()
        ub.dispose()
        web_server.stop(True)

    return view_configuration()