scidsg / hushline

Hush Line connects whistleblowers with organizations and people who can help.
https://hushline.app
GNU Affero General Public License v3.0
72 stars 21 forks source link

Deleting a user throws an exception #660

Closed glenn-sorrentino closed 4 weeks ago

glenn-sorrentino commented 4 weeks ago
[app] [2024-10-07 21:04:23] > Running migrations
[app] [2024-10-07 21:04:37] INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
[app] [2024-10-07 21:04:37] INFO  [alembic.runtime.migration] Will assume transactional DDL.
[app] [2024-10-07 21:04:38] > Configuring Stripe
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,282:INFO:Creating products and prices
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,306:INFO:message='Request to Stripe api' method=get url=https://api.stripe.com/v1/products/prod_QvDCAZq8arZxO8
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,543:INFO:message='Stripe API response' path=https://api.stripe.com/v1/products/prod_QvDCAZq8arZxO8 response_code=200
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,552:INFO:Product already exists for tier: Business
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,553:INFO:message='Request to Stripe api' method=get url=https://api.stripe.com/v1/prices/price_1Q7NViLcBPqjxU07Oi149NFd
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,642:INFO:message='Stripe API response' path=https://api.stripe.com/v1/prices/price_1Q7NViLcBPqjxU07Oi149NFd response_code=200
[app] [2024-10-07 21:04:46] 2024-10-07 21:04:46,643:INFO:Price already exists for tier: Business
[app] [2024-10-07 21:04:47] > Starting the server
[app] [2024-10-07 21:04:50] [2024-10-07 21:04:50 +0000] [9] [INFO] Starting gunicorn 22.0.0
[app] [2024-10-07 21:04:50] [2024-10-07 21:04:50 +0000] [9] [INFO] Listening at: http://0.0.0.0:8080 (9)
[app] [2024-10-07 21:04:50] [2024-10-07 21:04:50 +0000] [9] [INFO] Using worker: sync
[app] [2024-10-07 21:04:50] [2024-10-07 21:04:50 +0000] [12] [INFO] Booting worker with pid: 12
[app] [2024-10-07 21:04:59] /root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py:425: UserWarning: Current server name '10.244.151.121:8080' doesn't match configured server name 'staging.hushline.app'
[app] [2024-10-07 21:04:59]   return self.url_map.bind_to_environ(
[app] [2024-10-07 21:18:27] 2024-10-07 21:18:27,953:ERROR:Exception on /settings/delete-account [POST]
[app] [2024-10-07 21:18:27] Traceback (most recent call last):
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
[app] [2024-10-07 21:18:27]     self.dialect.do_execute(
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
[app] [2024-10-07 21:18:27]     cursor.execute(statement, parameters)
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
[app] [2024-10-07 21:18:27]     raise ex.with_traceback(None)
[app] [2024-10-07 21:18:27] psycopg.errors.NotNullViolation: null value in column "user_id" of relation "authentication_logs" violates not-null constraint
[app] [2024-10-07 21:18:27] DETAIL:  Failing row contains (2, null, t, 2024-10-07 21:17:51.540298, null, null).
[app] [2024-10-07 21:18:27] 
[app] [2024-10-07 21:18:27] The above exception was the direct cause of the following exception:
[app] [2024-10-07 21:18:27] 
[app] [2024-10-07 21:18:27] Traceback (most recent call last):
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
[app] [2024-10-07 21:18:27]     response = self.full_dispatch_request()
[app] [2024-10-07 21:18:27]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
[app] [2024-10-07 21:18:27]     rv = self.handle_user_exception(e)
[app] [2024-10-07 21:18:27]          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
[app] [2024-10-07 21:18:27]     rv = self.dispatch_request()
[app] [2024-10-07 21:18:27]          ^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
[app] [2024-10-07 21:18:27]     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
[app] [2024-10-07 21:18:27]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/app/hushline/utils.py", line 26, in decorated_function
[app] [2024-10-07 21:18:27]     return f(*args, **kwargs)
[app] [2024-10-07 21:18:27]            ^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/app/hushline/settings/__init__.py", line 681, in delete_account
[app] [2024-10-07 21:18:27]     db.session.commit()
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/scoping.py", line 597, in commit
[app] [2024-10-07 21:18:27]     return self._proxied.commit()
[app] [2024-10-07 21:18:27]            ^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2028, in commit
[app] [2024-10-07 21:18:27]     trans.commit(_to_root=True)
[app] [2024-10-07 21:18:27]   File "<string>", line 2, in commit
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
[app] [2024-10-07 21:18:27]     ret_value = fn(self, *arg, **kw)
[app] [2024-10-07 21:18:27]                 ^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 1313, in commit
[app] [2024-10-07 21:18:27]     self._prepare_impl()
[app] [2024-10-07 21:18:27]   File "<string>", line 2, in _prepare_impl
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/state_changes.py", line 139, in _go
[app] [2024-10-07 21:18:27]     ret_value = fn(self, *arg, **kw)
[app] [2024-10-07 21:18:27]                 ^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 1288, in _prepare_impl
[app] [2024-10-07 21:18:27]     self.session.flush()
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4352, in flush
[app] [2024-10-07 21:18:27]     self._flush(objects)
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4487, in _flush
[app] [2024-10-07 21:18:27]     with util.safe_reraise():
[app] [2024-10-07 21:18:27]          ^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
[app] [2024-10-07 21:18:27]     raise exc_value.with_traceback(exc_tb)
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 4448, in _flush
[app] [2024-10-07 21:18:27]     flush_context.execute()
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
[app] [2024-10-07 21:18:27]     rec.execute(self)
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
[app] [2024-10-07 21:18:27]     util.preloaded.orm_persistence.save_obj(
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 85, in save_obj
[app] [2024-10-07 21:18:27]     _emit_update_statements(
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 912, in _emit_update_statements
[app] [2024-10-07 21:18:27]     c = connection.execute(
[app] [2024-10-07 21:18:27]         ^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
[app] [2024-10-07 21:18:27]     return meth(
[app] [2024-10-07 21:18:27]            ^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
[app] [2024-10-07 21:18:27]     return connection._execute_clauseelement(
[app] [2024-10-07 21:18:27]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
[app] [2024-10-07 21:18:27]     ret = self._execute_context(
[app] [2024-10-07 21:18:27]           ^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
[app] [2024-10-07 21:18:27]     return self._exec_single_context(
[app] [2024-10-07 21:18:27]            ^^^^^^^^^^^^^^^^^^^^^^^^^^
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
[app] [2024-10-07 21:18:27]     self._handle_dbapi_exception(
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
[app] [2024-10-07 21:18:27]     raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
[app] [2024-10-07 21:18:27]     self.dialect.do_execute(
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
[app] [2024-10-07 21:18:27]     cursor.execute(statement, parameters)
[app] [2024-10-07 21:18:27]   File "/root/.cache/pypoetry/virtualenvs/hushline-9TtSrW0h-py3.12/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
[app] [2024-10-07 21:18:27]     raise ex.with_traceback(None)
[app] [2024-10-07 21:18:27] sqlalchemy.exc.IntegrityError: (psycopg.errors.NotNullViolation) null value in column "user_id" of relation "authentication_logs" violates not-null constraint
[app] [2024-10-07 21:18:27] DETAIL:  Failing row contains (2, null, t, 2024-10-07 21:17:51.540298, null, null).
[app] [2024-10-07 21:18:27] [SQL: UPDATE authentication_logs SET user_id=%(user_id)s::INTEGER WHERE authentication_logs.id = %(authentication_logs_id)s::INTEGER]
[app] [2024-10-07 21:18:27] [parameters: {'user_id': None, 'authentication_logs_id': 2}]
[app] [2024-10-07 21:18:27] (Background on this error at: https://sqlalche.me/e/20/gkpj)
brassy-endomorph commented 4 weeks ago

I would just like to point out the the bug is triggered by the endpoint on line 666 of some module, and this is somewhat amusing.