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)