From def66355587c485a87c2559c842047a41622d8fd Mon Sep 17 00:00:00 2001 From: benoit74 Date: Tue, 24 Oct 2023 11:21:23 +0200 Subject: [PATCH] Quick fix for issue on /schedules/backup endpoint which was modifying secret flags --- dispatcher/backend/src/routes/schedules/schedule.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dispatcher/backend/src/routes/schedules/schedule.py b/dispatcher/backend/src/routes/schedules/schedule.py index cd823321..1502a89d 100644 --- a/dispatcher/backend/src/routes/schedules/schedule.py +++ b/dispatcher/backend/src/routes/schedules/schedule.py @@ -1,4 +1,5 @@ import base64 +import copy import logging from http import HTTPStatus @@ -168,7 +169,9 @@ def get(self, token: AccessToken.Payload, session: so.Session): """Return all schedules backup""" def dump(schedule): - payload = ScheduleFullSchema(exclude=("most_recent_task",)).dump(schedule) + payload = copy.deepcopy( + ScheduleFullSchema(exclude=("most_recent_task",)).dump(schedule) + ) if not token or not token.get_permission("schedules", "update"): payload["notification"] = None @@ -177,7 +180,7 @@ def dump(schedule): return payload stmt = sa.select(dbm.Schedule).order_by(dbm.Schedule.name) - return jsonify( + result = jsonify( list( map( dump, @@ -186,6 +189,11 @@ def dump(schedule): ) ) + if session.new or session.dirty or session.deleted: + raise BadRequest("Unexpected modifications occured") + + return result + class ScheduleRoute(BaseRoute): rule = "/"