Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(framework) Add request validation to ServerAppIoServicer #4720

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/py/flwr/server/superlink/driver/serverappio_servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def PushTaskIns(
for task_ins in request.task_ins_list:
validation_errors = validate_task_ins_or_res(task_ins)
_raise_if(bool(validation_errors), ", ".join(validation_errors))
_raise_if(
request.run_id != task_ins.run_id, "`task_ins` has mismatched `run_id`"
)

# Store each TaskIns
task_ids: list[Optional[UUID]] = []
Expand Down Expand Up @@ -193,6 +196,12 @@ def PullTaskRes(
# Read from state
task_res_list: list[TaskRes] = state.get_task_res(task_ids=task_ids)

# Validate request
for task_res in task_res_list:
_raise_if(
request.run_id != task_res.run_id, "`task_res` has mismatched `run_id`"
)

# Delete the TaskIns/TaskRes pairs if TaskRes is found
task_ins_ids_to_delete = {
UUID(task_res.task.ancestry[0]) for task_res in task_res_list
Expand Down