Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check type of event fields when creating events and do not return a 500 Internal Server Error in POST /events #136

Open
stephanegigandet opened this issue Sep 7, 2022 · 0 comments

Comments

@stephanegigandet
Copy link

I posted a barcode as a string, which results in an unhandled exception and a 500 Internal Server Error being returned to the client.

stephanegigandet@dockers:/home/off/events-net$ sudo docker-compose logs --tail 100  api
Attaching to events_api_1
api_1       |     raise exception
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 3463, in _flush
api_1       |     flush_context.execute()
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
api_1       |     rec.execute(self)
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
api_1       |     util.preloaded.orm_persistence.save_obj(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
api_1       |     _emit_insert_statements(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 1238, in _emit_insert_statements
api_1       |     result = connection._execute_20(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
api_1       |     return meth(self, args_10style, kwargs_10style, execution_options)
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
api_1       |     return connection._execute_clauseelement(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
api_1       |     ret = self._execute_context(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
api_1       |     self._handle_dbapi_exception(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
api_1       |     util.raise_(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
api_1       |     raise exception
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
api_1       |     self.dialect.do_execute(
api_1       |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
api_1       |     cursor.execute(statement, parameters)
api_1       | sqlalchemy.exc.DataError: (psycopg2.errors.NumericValueOutOfRange) value "3270160503070" is out of range for type integer
api_1       | LINE 1: ...roduct_edited', '2022-09-07T13:06:16'::timestamp, '327016050...
api_1       |                                                              ^
api_1       | 
api_1       | [SQL: INSERT INTO events (user_id, device_id, event_type, timestamp, barcode, points) VALUES (%(user_id)s, %(device_id)s, %(event_type)s, %(timestamp)s, %(barcode)s, %(points)s) RETURNING events.id]
api_1       | [parameters: {'user_id': 'test2', 'device_id': None, 'event_type': 'product_edited', 'timestamp': datetime.datetime(2022, 9, 7, 13, 6, 16), 'barcode': '3270160503070', 'points': 10}]
api_1       | (Background on this error at: https://sqlalche.me/e/14/9h9h)
@teolemon teolemon added the bug Something isn't working label Dec 13, 2022
@teolemon teolemon removed the bug Something isn't working label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants