From b000707825bc8a80c455ffc8b5f1f136f29c5937 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 23 Jan 2024 12:24:28 -0800 Subject: [PATCH] Properly handle list shaped details. --- kolibri/plugins/user_profile/tasks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kolibri/plugins/user_profile/tasks.py b/kolibri/plugins/user_profile/tasks.py index 173607d3c61..c16d84422d5 100644 --- a/kolibri/plugins/user_profile/tasks.py +++ b/kolibri/plugins/user_profile/tasks.py @@ -42,10 +42,15 @@ def validate(self, data): try: job_data = super(MergeUserValidator, self).validate(data) except ValidationError as e: - if e.detail.code == error_constants.AUTHENTICATION_FAILED: - self.create_remote_user(data) - job_data = super(MergeUserValidator, self).validate(data) + details = e.detail if isinstance(e.detail, list) else [e.detail] + for detail in details: + # If any of the errors are authentication related, then we need to create the user + if detail.code == error_constants.AUTHENTICATION_FAILED: + self.create_remote_user(data) + job_data = super(MergeUserValidator, self).validate(data) + break else: + # If we didn't break out of the loop, then we need to raise the original error raise job_data["kwargs"]["local_user_id"] = data["local_user_id"].id