SamWheating commented on a change in pull request #18590:
URL: https://github.com/apache/airflow/pull/18590#discussion_r718922743
##########
File path: airflow/cli/commands/user_command.py
##########
@@ -159,27 +160,32 @@ def users_import(args):
if not os.path.exists(json_file):
raise SystemExit(f"File '{json_file}' does not exist")
- users_list = None
+ users_list_ = None
try:
with open(json_file) as file:
- users_list = json.loads(file.read())
+ users_list_ = json.loads(file.read())
except ValueError as e:
raise SystemExit(f"File '{json_file}' is not valid JSON. Error: {e}")
- users_created, users_updated = _import_users(users_list)
+ users_created, users_updated = _import_users(users_list_)
if users_created:
print("Created the following
users:\n\t{}".format("\n\t".join(users_created)))
if users_updated:
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:
+ for user in users_list_:
+ required_fields = ['username', 'firstname', 'lastname', 'email',
'roles']
+ for field in required_fields:
+ if field not in user:
Review comment:
So this will still permit the creation of a user with `roles=[]` without
erroring. Is that OK, or was the rejection of a user with no roles intended?
--
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]