From 5713b80abb79e49361b1f1d03a8ff52ee92b0d64 Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Thu, 2 Nov 2023 10:35:34 +0000 Subject: [PATCH] Fixed #844: raise HTTP 400 on IntegrityError during Clone Same behavior as for schedule creation (that API supports but UI does not) --- dispatcher/backend/src/routes/schedules/schedule.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dispatcher/backend/src/routes/schedules/schedule.py b/dispatcher/backend/src/routes/schedules/schedule.py index 1502a89d..90ef3c69 100644 --- a/dispatcher/backend/src/routes/schedules/schedule.py +++ b/dispatcher/backend/src/routes/schedules/schedule.py @@ -382,6 +382,9 @@ def post(self, schedule_name: str, token: AccessToken.Payload, session: so.Sessi ) clone.durations.append(duration) - session.flush() + try: + session.flush() + except IntegrityError: + raise BadRequest("Schedule name already exists") return make_response(jsonify({"_id": str(clone.id)}), HTTPStatus.CREATED)