Skip to content

Commit

Permalink
Quick fix for issue on /schedules/backup endpoint which was modifying…
Browse files Browse the repository at this point in the history
… secret flags
  • Loading branch information
benoit74 committed Oct 24, 2023
1 parent 05fcfdd commit def6635
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dispatcher/backend/src/routes/schedules/schedule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import copy
import logging
from http import HTTPStatus

Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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 = "/<string:schedule_name>"
Expand Down

0 comments on commit def6635

Please sign in to comment.