-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
If one tries to edit a language object and new values are not presented in the DB then status 500 will be returned.
It happens because we don't check if these new values already exist in the DB. If they're not here then we violate foreign key constraint and an exception is raised:
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) insert or update on table "dictionaryperspective" violates foreign key constraint "dictionaryperspective_parent_object_id_fkey"
We need to add try/catch blocks and return a proper answer.
Example of a problem code:
if language:
if not language.marked_for_deletion:
# TODO: Status 500 will be returned if arguments are invalid; add try/catch
req = request.json_body
if 'parent_client_id' in req:
language.parent_client_id = req['parent_client_id']
if 'parent_object_id' in req:
language.parent_object_id = req['parent_object_id']
if 'translation_gist_client_id' in req:
language.translation_gist_client_id = req['translation_gist_client_id']
if 'translation_gist_object_id' in req:
language.translation_gist_object_id = req['translation_gist_object_id']
request.response.status = HTTPOk.code
return response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels