Cannot login "no such table: users" Bare metal installation
Pantamis opened this issue · comments
Describe the bug
When trying to login on the web page, nothing happen.
The logs of wg-manager return this:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users
[SQL: SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username, users.full_name AS users_full_name, users.role AS users_role
FROM users
WHERE users.username = ?]
[parameters: ('admin',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
To Reproduce
Steps to reproduce the behavior:
- Follow the installation guide for Bare metal RPi
- Run the on the Pi with uvicorn
- Complete password for admin (admin in the guide) on web page on another computer of the local network
- Nothing happen and the logs above are returned in the Pi
Platform:
- OS: RPI 4 Raspberry Pi OS 64 bits
- Browser Brave
- Version git-commit: latest main branch a2e3824
Thanks for help !
Stacktrace/error output
2021-06-18 16:47:37.797 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
2021-06-18 16:47:37.798 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
2021-06-18 16:47:37.798 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
2021-06-18 16:47:38.463 | DEBUG | passlib.registry:register_crypt_handler:296 - registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
INFO: Started server process [26511]
2021-06-18 16:47:40.382 | INFO | uvicorn.server:serve:65 - Started server process [26511]
INFO: Waiting for application startup.
2021-06-18 16:47:40.384 | INFO | uvicorn.lifespan.on:startup:45 - Waiting for application startup.
INFO: Application startup complete.
2021-06-18 16:47:40.386 | INFO | uvicorn.lifespan.on:startup:59 - Application startup complete.
INFO: Uvicorn running on http://[hidden_local_IP] (Press CTRL+C to quit)
2021-06-18 16:47:40.389 | INFO | uvicorn.server:_log_started_message:207 - Uvicorn running on http://[hidden] (Press CTRL+C to quit)
2021-06-18 16:47:42.440 | DEBUG | multipart.multipart:callback:604 - Calling on_part_begin with no data
2021-06-18 16:47:42.442 | DEBUG | multipart.multipart:callback:601 - Calling on_header_field with data[42:61]
2021-06-18 16:47:42.443 | DEBUG | multipart.multipart:callback:601 - Calling on_header_value with data[63:89]
2021-06-18 16:47:42.443 | DEBUG | multipart.multipart:callback:604 - Calling on_header_end with no data
2021-06-18 16:47:42.444 | DEBUG | multipart.multipart:callback:604 - Calling on_headers_finished with no data
2021-06-18 16:47:42.445 | DEBUG | multipart.multipart:callback:601 - Calling on_part_data with data[93:98]
2021-06-18 16:47:42.446 | DEBUG | multipart.multipart:callback:604 - Calling on_part_end with no data
2021-06-18 16:47:42.447 | DEBUG | multipart.multipart:callback:604 - Calling on_part_begin with no data
2021-06-18 16:47:42.448 | DEBUG | multipart.multipart:callback:601 - Calling on_header_field with data[142:161]
2021-06-18 16:47:42.449 | DEBUG | multipart.multipart:callback:601 - Calling on_header_value with data[163:189]
2021-06-18 16:47:42.449 | DEBUG | multipart.multipart:callback:604 - Calling on_header_end with no data
2021-06-18 16:47:42.450 | DEBUG | multipart.multipart:callback:604 - Calling on_headers_finished with no data
2021-06-18 16:47:42.451 | DEBUG | multipart.multipart:callback:601 - Calling on_part_data with data[193:194]
2021-06-18 16:47:42.452 | DEBUG | multipart.multipart:callback:604 - Calling on_part_end with no data
2021-06-18 16:47:42.453 | DEBUG | multipart.multipart:callback:604 - Calling on_end with no data
2021-06-18 16:47:42,486 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2021-06-18 16:47:42.486 | INFO | sqlalchemy.log:log:156 - SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2021-06-18 16:47:42,487 INFO sqlalchemy.engine.base.Engine ()
2021-06-18 16:47:42.487 | INFO | sqlalchemy.log:log:156 - ()
2021-06-18 16:47:42,489 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2021-06-18 16:47:42.489 | INFO | sqlalchemy.log:log:156 - SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2021-06-18 16:47:42,490 INFO sqlalchemy.engine.base.Engine ()
2021-06-18 16:47:42.490 | INFO | sqlalchemy.log:log:156 - ()
2021-06-18 16:47:42,496 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2021-06-18 16:47:42.496 | INFO | sqlalchemy.log:log:156 - BEGIN (implicit)
2021-06-18 16:47:42,499 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username, users.full_name AS users_full_name, users.role AS users_role
FROM users
WHERE users.username = ?
2021-06-18 16:47:42.499 | INFO | sqlalchemy.log:log:156 - SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username, users.full_name AS users_full_name, users.role AS users_role
FROM users
WHERE users.username = ?
2021-06-18 16:47:42,500 INFO sqlalchemy.engine.base.Engine ('admin',)
2021-06-18 16:47:42.500 | INFO | sqlalchemy.log:log:156 - ('admin',)
2021-06-18 16:47:42,502 INFO sqlalchemy.engine.base.Engine ROLLBACK
2021-06-18 16:47:42.503 | INFO | sqlalchemy.log:log:156 - ROLLBACK
INFO: [hidden_local_IP]:36530 - "POST /api/v1/login HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 371, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 59, in __call__
return await self.app(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/applications.py", line 199, in __call__
await super().__call__(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 25, in __call__
response = await self.dispatch_func(request, self.call_next)
File "./middleware.py", line 32, in logging_middleware
response = await call_next(request)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 45, in call_next
task.result()
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 38, in coro
await self.app(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 25, in __call__
response = await self.dispatch_func(request, self.call_next)
File "./middleware.py", line 41, in db_session_middleware
response = await call_next(request)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 45, in call_next
task.result()
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 38, in coro
await self.app(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 580, in __call__
await route.handle(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 52, in app
response = await func(request)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/routing.py", line 215, in app
dependant=dependant, values=values, is_coroutine=is_coroutine
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/routing.py", line 151, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "./routers/v1/user.py", line 81, in login
user: schemas.UserInDB = schemas.UserInDB(username=username, password="").from_db(sess)
File "./schemas.py", line 74, in from_db
db_item = self.filter_query(sess).one()
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3490, in one
ret = self.one_or_none()
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3459, in one_or_none
ret = list(self)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
return self._execute_and_instances(context)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
return meth(self, multiparams, params)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
distilled_params,
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
e, statement, parameters, cursor, context
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from_=e
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
cursor, statement, parameters, context
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users
[SQL: SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username, users.full_name AS users_full_name, users.role AS users_role
FROM users
WHERE users.username = ?]
[parameters: ('admin',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
2021-06-18 16:47:42.535 | ERROR | uvicorn.protocols.http.httptools_impl:run_asgi:374 - Exception in ASGI application
Traceback (most recent call last):
File "/opt/wg-manager/wg-manager-backend/venv/bin/uvicorn", line 10, in <module>
sys.exit(main())
│ │ └ <Command main>
│ └ <built-in function exit>
└ <module 'sys' (built-in)>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
│ │ │ └ {}
│ │ └ ()
│ └ <function BaseCommand.main at 0x7fbabd5488>
└ <Command main>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
│ │ └ <click.core.Context object at 0x7fbb3df9b0>
│ └ <function Command.invoke at 0x7fbabd5ea0>
└ <Command main>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
│ │ │ │ │ └ {'host': '[hidden_local_IP]', 'port': 5000, 'app': 'main:app', 'uds': None, 'fd': None, 'debug': False, 'reload': False, 'reload_d...
│ │ │ │ └ <click.core.Context object at 0x7fbb3df9b0>
│ │ │ └ <function main at 0x7fba95b488>
│ │ └ <Command main>
│ └ <function Context.invoke at 0x7fbabced08>
└ <click.core.Context object at 0x7fbb3df9b0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
│ └ {'host': '[hidden_local_IP]', 'port': 5000, 'app': 'main:app', 'uds': None, 'fd': None, 'debug': False, 'reload': False, 'reload_d...
└ ()
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/main.py", line 371, in main
run(app, **kwargs)
│ │ └ {'host': '[hidden_local_IP]', 'port': [hidden_local_IP], 'uds': None, 'fd': None, 'loop': 'auto', 'http': 'auto', 'ws': 'auto', 'ws_max_size': ...
│ └ 'main:app'
└ <function run at 0x7fbb282bf8>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/main.py", line 393, in run
server.run()
│ └ <function Server.run at 0x7fbb282730>
└ <uvicorn.server.Server object at 0x7fba963898>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/server.py", line 50, in run
loop.run_until_complete(self.serve(sockets=sockets))
│ │ │ │ └ None
│ │ │ └ <function Server.serve at 0x7fbb2827b8>
│ │ └ <uvicorn.server.Server object at 0x7fba963898>
│ └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
└ <uvloop.Loop running=True closed=False debug=False>
> File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 371, in run_asgi
result = await app(self.scope, self.receive, self.send)
│ │ │ │ │ │ └ <function RequestResponseCycle.send at 0x7fba715ae8>
│ │ │ │ │ └ <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>
│ │ │ │ └ <function RequestResponseCycle.receive at 0x7fba715b70>
│ │ │ └ <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>
└ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x7fba91f9e8>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 59, in __call__
return await self.app(scope, receive, send)
│ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <fastapi.applications.FastAPI object at 0x7fba6f41d0>
└ <uvicorn.middleware.proxy_headers.ProxyHeadersMiddleware object at 0x7fba91f9e8>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/applications.py", line 199, in __call__
await super().__call__(scope, receive, send)
│ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>>
│ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
└ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
│ │ │ │ └ <bound method RequestResponseCycle.send of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8beec88>>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <starlette.middleware.errors.ServerErrorMiddleware object at 0x7fb8c3e048>
└ <fastapi.applications.FastAPI object at 0x7fba6f41d0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
│ │ │ │ └ <function ServerErrorMiddleware.__call__.<locals>._send at 0x7fb8befb70>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caefd0>
└ <starlette.middleware.errors.ServerErrorMiddleware object at 0x7fb8c3e048>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 25, in __call__
response = await self.dispatch_func(request, self.call_next)
│ │ │ │ └ <function BaseHTTPMiddleware.call_next at 0x7fba506158>
│ │ │ └ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caefd0>
│ │ └ <starlette.requests.Request object at 0x7fb8beed68>
│ └ <function logging_middleware at 0x7fb96d87b8>
└ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caefd0>
File "./middleware.py", line 32, in logging_middleware
response = await call_next(request)
│ └ <starlette.requests.Request object at 0x7fb8beed68>
└ <bound method BaseHTTPMiddleware.call_next of <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caefd0>>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 45, in call_next
task.result()
│ └ <method 'result' of '_asyncio.Task' objects>
└ <Task finished coro=<BaseHTTPMiddleware.call_next.<locals>.coro() done, defined at /opt/wg-manager/wg-manager-backend/venv/li...
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 38, in coro
await self.app(scope, receive, send)
│ │ │ │ └ <bound method Queue.put of <Queue at 0x7fb8beec50 maxsize=0 tasks=1>>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caef98>
└ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caefd0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 25, in __call__
response = await self.dispatch_func(request, self.call_next)
│ │ │ │ └ <function BaseHTTPMiddleware.call_next at 0x7fba506158>
│ │ │ └ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caef98>
│ │ └ <starlette.requests.Request object at 0x7fb8beec18>
│ └ <function db_session_middleware at 0x7fb96d8840>
└ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caef98>
File "./middleware.py", line 41, in db_session_middleware
response = await call_next(request)
│ └ <starlette.requests.Request object at 0x7fb8beec18>
└ <bound method BaseHTTPMiddleware.call_next of <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caef98>>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 45, in call_next
task.result()
│ └ <method 'result' of '_asyncio.Task' objects>
└ <Task finished coro=<BaseHTTPMiddleware.call_next.<locals>.coro() done, defined at /opt/wg-manager/wg-manager-backend/venv/li...
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 38, in coro
await self.app(scope, receive, send)
│ │ │ │ └ <bound method Queue.put of <Queue at 0x7fb8b88080 maxsize=0 tasks=1>>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <starlette.exceptions.ExceptionMiddleware object at 0x7fb8caeeb8>
└ <starlette.middleware.base.BaseHTTPMiddleware object at 0x7fb8caef98>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
│ │ │ │ └ <function ExceptionMiddleware.__call__.<locals>.sender at 0x7fb8beff28>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <fastapi.routing.APIRouter object at 0x7fb92ac080>
└ <starlette.exceptions.ExceptionMiddleware object at 0x7fb8caeeb8>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 580, in __call__
await route.handle(scope, receive, send)
│ │ │ │ └ <function ExceptionMiddleware.__call__.<locals>.sender at 0x7fb8beff28>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <function Route.handle at 0x7fba1ab378>
└ <fastapi.routing.APIRoute object at 0x7fb8c3eef0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
│ │ │ │ └ <function ExceptionMiddleware.__call__.<locals>.sender at 0x7fb8beff28>
│ │ │ └ <bound method RequestResponseCycle.receive of <uvicorn.protocols.http.httptools_impl.RequestResponseCycle object at 0x7fb8bee...
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.1'}, 'http_version': '1.1', 'server': ([hidden_local_IP]), ...
│ └ <function request_response.<locals>.app at 0x7fb8c4dc80>
└ <fastapi.routing.APIRoute object at 0x7fb8c3eef0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 52, in app
response = await func(request)
│ └ <starlette.requests.Request object at 0x7fb8b88128>
└ <function get_request_handler.<locals>.app at 0x7fb8c4da60>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/routing.py", line 215, in app
dependant=dependant, values=values, is_coroutine=is_coroutine
│ │ └ False
│ └ {'sess': <sqlalchemy.orm.session.Session object at 0x7fb8beee10>, 'username': 'admin', 'password': ' '}
└ <fastapi.dependencies.models.Dependant object at 0x7fb8c520b8>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/fastapi/routing.py", line 151, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
│ │ │ └ {'sess': <sqlalchemy.orm.session.Session object at 0x7fb8beee10>, 'username': 'admin', 'password': ' '}
│ │ └ <function login at 0x7fb9700400>
│ └ <fastapi.dependencies.models.Dependant object at 0x7fb8c520b8>
└ <function run_in_threadpool at 0x7fba573620>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
│ │ │ └ (functools.partial(<function login at 0x7fb9700400>, sess=<sqlalchemy.orm.session.Session object at 0x7fb8beee10>, username='...
│ │ └ <built-in method run of Context object at 0x7fb8b8ca20>
│ └ <method 'run_in_executor' of 'uvloop.loop.Loop' objects>
└ <uvloop.Loop running=True closed=False debug=False>
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
│ │ └ None
│ └ None
└ None
File "./routers/v1/user.py", line 81, in login
user: schemas.UserInDB = schemas.UserInDB(username=username, password="").from_db(sess)
│ │ │ │ │ └ <sqlalchemy.orm.session.Session object at 0x7fb8beee10>
│ │ │ │ └ 'admin'
│ │ │ └ <class 'schemas.UserInDB'>
│ │ └ <module 'schemas' from './schemas.py'>
│ └ <class 'schemas.UserInDB'>
└ <module 'schemas' from './schemas.py'>
File "./schemas.py", line 74, in from_db
db_item = self.filter_query(sess).one()
│ │ └ <sqlalchemy.orm.session.Session object at 0x7fb8beee10>
│ └ <function GenericModel.filter_query at 0x7fb9937268>
└ UserInDB(id=None, username='admin', email=None, full_name=None, role=None, password='')
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3490, in one
ret = self.one_or_none()
│ └ <function Query.one_or_none at 0x7fb9a3c378>
└ <sqlalchemy.orm.query.Query object at 0x7fb8b88be0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3459, in one_or_none
ret = list(self)
└ <sqlalchemy.orm.query.Query object at 0x7fb8b88be0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
return self._execute_and_instances(context)
│ │ └ <sqlalchemy.orm.query.QueryContext object at 0x7fb8ce4360>
│ └ <function Query._execute_and_instances at 0x7fb9a3c730>
└ <sqlalchemy.orm.query.Query object at 0x7fb8b88be0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
│ │ │ │ │ └ immutabledict({})
│ │ │ │ └ <sqlalchemy.orm.query.Query object at 0x7fb8b88be0>
│ │ │ └ <member 'statement' of 'QueryContext' objects>
│ │ └ <sqlalchemy.orm.query.QueryContext object at 0x7fb8ce4360>
│ └ <function Connection.execute at 0x7fb9d2c510>
└ <sqlalchemy.engine.base.Connection object at 0x7fb5b35a58>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
return meth(self, multiparams, params)
│ │ │ └ {}
│ │ └ (immutabledict({}),)
│ └ <sqlalchemy.engine.base.Connection object at 0x7fb5b35a58>
└ <bound method ClauseElement._execute_on_connection of <sqlalchemy.sql.selectable.Select at 0x7fb8b88940; Select object>>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
│ │ │ │ └ {}
│ │ │ └ (immutabledict({}),)
│ │ └ <sqlalchemy.sql.selectable.Select at 0x7fb8b88940; Select object>
│ └ <function Connection._execute_clauseelement at 0x7fb9d2c730>
└ <sqlalchemy.engine.base.Connection object at 0x7fb5b35a58>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
distilled_params,
└ [immutabledict({})]
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
e, statement, parameters, cursor, context
│ │ │ └ <sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext object at 0x7fb5b35b70>
│ │ └ <sqlite3.Cursor object at 0x7fb8bed9d0>
│ └ ('admin',)
└ 'SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username,...
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from_=e
│ │ └ OperationalError('no such table: users')
│ └ (<class 'sqlite3.OperationalError'>, OperationalError('no such table: users'), <traceback object at 0x7fb5b4fd48>)
└ OperationalError('(sqlite3.OperationalError) no such table: users')
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
cursor, statement, parameters, context
│ │ │ └ <sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext object at 0x7fb5b35b70>
│ │ └ ('admin',)
│ └ 'SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username,...
└ <sqlite3.Cursor object at 0x7fb8bed9d0>
File "/opt/wg-manager/wg-manager-backend/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
cursor.execute(statement, parameters)
│ │ │ └ ('admin',)
│ │ └ 'SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username,...
│ └ <method 'execute' of 'sqlite3.Cursor' objects>
└ <sqlite3.Cursor object at 0x7fb8bed9d0>
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users
[SQL: SELECT users.id AS users_id, users.email AS users_email, users.password AS users_password, users.username AS users_username, users.full_name AS users_full_name, users.role AS users_role
FROM users
WHERE users.username = ?]
[parameters: ('admin',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
^CINFO: Shutting down
2021-06-18 16:47:44.811 | INFO | uvicorn.server:shutdown:242 - Shutting down
INFO: Waiting for application shutdown.
2021-06-18 16:47:44.913 | INFO | uvicorn.lifespan.on:shutdown:64 - Waiting for application shutdown.
INFO: Application shutdown complete.
2021-06-18 16:47:44.914 | INFO | uvicorn.lifespan.on:shutdown:75 - Application shutdown complete.
INFO: Finished server process [26511]
2021-06-18 16:47:44.915 | INFO | uvicorn.server:serve:78 - Finished server process [26511]
I run Raspberry Pi OS 64 bits on the Pi 4B with 4GB of RAM !
You can get the OS image for 64 bits (still beta) here: https://downloads.raspberrypi.org/raspios_arm64/images/
Thanks :)
I'm not able to replicate this issue.
- Do you have an existing database from prior installations, or is this a fresh installation?
- Did you get any errors during the first run of the application?
- Could you try deleting database.db and rerun the application? Does this work?
I'll have to check the installation guide, but if all env variables are set, the creation of the user table should work fine:
My logs during clean run (without database.db) WITH environment variables set
2021-06-19 16:45:25.782 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
2021-06-19 16:45:25.782 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
2021-06-19 16:45:25.782 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
2021-06-19 16:45:25.898 | DEBUG | passlib.registry:register_crypt_handler:296 - registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
2021-06-19 16:45:26.187 | INFO | database.util:setup_initial_database:28 - Database does not exists. Creating initial database...
2021-06-19 16:45:26.251 | INFO | database.util:setup_initial_database:32 - Database creation done!
2021-06-19 16:45:26.252 | INFO | database.util:setup_initial_database:41 - Admin user does not exists. Creating with env variables ADMIN_USERNAME, ADMIN_PASSWORD
2021-06-19 16:45:26.256 | DEBUG | passlib.handlers.bcrypt:_load_backend_mixin:625 - detected 'bcrypt' backend, version '3.2.0'
2021-06-19 16:45:26.256 | DEBUG | passlib.handlers.bcrypt:_finalize_backend_mixin:406 - 'bcrypt' backend lacks $2$ support, enabling workaround
2021-06-19 16:45:26.475 | INFO | database.util:perform_migrations:15 - Performing migrations...
2021-06-19 16:45:26.477 | INFO | alembic.runtime.migration:__init__:163 - Context impl SQLiteImpl.
2021-06-19 16:45:26.477 | INFO | alembic.runtime.migration:__init__:166 - Will assume non-transactional DDL.
2021-06-19 16:45:26.488 | INFO | alembic.runtime.migration:run_migrations:555 - Running upgrade -> 4ac3e58519eb, base
2021-06-19 16:45:26.517 | DEBUG | alembic.runtime.migration:update_to_step:751 - new branch insert 4ac3e58519eb
2021-06-19 16:45:26.522 | INFO | database.util:perform_migrations:23 - Migrations done!
2021-06-19 16:45:26.695 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
2021-06-19 16:45:26.695 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
2021-06-19 16:45:26.695 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
2021-06-19 16:45:26.788 | DEBUG | passlib.registry:register_crypt_handler:296 - registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
Logs on clean install WITHOUT envs set:
2021-06-19 16:49:49.788 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'SafeConfigParser': <class 'configparser.ConfigParser'>
2021-06-19 16:49:49.788 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'NativeStringIO': <class '_io.StringIO'>
2021-06-19 16:49:49.788 | DEBUG | passlib.utils.compat:__getattr__:449 - loaded lazy attr 'BytesIO': <class '_io.BytesIO'>
2021-06-19 16:49:49.878 | DEBUG | passlib.registry:register_crypt_handler:296 - registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
2021-06-19 16:49:50.102 | INFO | database.util:setup_initial_database:28 - Database does not exists. Creating initial database...
2021-06-19 16:49:50.169 | INFO | database.util:setup_initial_database:32 - Database creation done!
2021-06-19 16:49:50.170 | INFO | database.util:setup_initial_database:41 - Admin user does not exists. Creating with env variables ADMIN_USERNAME, ADMIN_PASSWORD
Traceback (most recent call last):
File "/home/per/git/code/wg-dashboard-py/wg-manager-backend/main.py", line 85, in <module>
database.util.setup_initial_database()
File "/home/per/git/code/wg-dashboard-py/wg-manager-backend/database/util.py", line 46, in setup_initial_database
raise RuntimeError("Database does not exist and the environment variable ADMIN_USERNAME is set")
RuntimeError: Database does not exist and the environment variable ADMIN_USERNAME is set
Okay! I've figured it out. Basically, when running with the uviron command, the main function which sets up database etc does not run. I've fixed this now. Furthermore I've updated the guide. If you have installed wg-manager on /opt you should change the ownership to the correct user: sudo chown <user>:<user> -R /opt/wg-manager
and not user sudo when running the application.
You fixed it, I can successfully login, thanks for your very quick fix :)
I already have a wireguard server in /etc/wireguard/wg0.conf running on the RPi, do I have to import it to see it in the manager ? Should I also disable it and enable it only though wg-manager ?
Thanks again :)
Hi, Yes, you will have to import into wireguard. I cannot remember if you have to shut the existing wireguard off before importing, but I think so...
Also, I have not tested the import function in a while so I'm crossing my fingers that It will work for you without issues!