Skip to content

Commit

Permalink
Fixed #844: raise HTTP 400 on IntegrityError during Clone
Browse files Browse the repository at this point in the history
Same behavior as for schedule creation (that API supports but UI does not)
  • Loading branch information
rgaudin committed Nov 2, 2023
1 parent aa387e3 commit 5713b80
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dispatcher/backend/src/routes/schedules/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 5713b80

Please sign in to comment.