uranusjr commented on a change in pull request #18590:
URL: https://github.com/apache/airflow/pull/18590#discussion_r732237155
##########
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:
`user` is a dict here so quoting it is probably not going to be
particularly legible. We should probably find another way. I wonder if it'd be
better to validate `users_list` in its entirety instead; Marshmallow provides
pretty good context on list items out of the box (something like *Item 1 in
list is invalid*).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]