You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/10/20 10:38:50 UTC

[GitHub] [airflow] khalidmammadov commented on a change in pull request #18590: Fixing bug when roles list is empty

khalidmammadov commented on a change in pull request #18590:
URL: https://github.com/apache/airflow/pull/18590#discussion_r732640318



##########
File path: airflow/cli/commands/user_command.py
##########
@@ -174,12 +189,19 @@ def users_import(args):
         print("Updated the following users:\n\t{}".format("\n\t".join(users_updated)))
 
 
-def _import_users(users_list):
+def _import_users(users_list: List[Dict[str, Any]]):
     appbuilder = cached_app().appbuilder
     users_created = []
     users_updated = []
 
     for user in users_list:
+
+        try:
+            # Validate structure
+            UserSchema().load(user)
+        except ValidationError as e:
+            raise SystemExit(f"Error: Can't load user \"{user}\". \nDetails:{e}")

Review comment:
       Agreed. Added whole file validation before starting the import. Updated tests accordingly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org