From 0b25e3e3395471524878cdd0d1bc4fff1fed69c0 Mon Sep 17 00:00:00 2001 From: Maurane GLAUDE Date: Wed, 27 Nov 2024 17:42:42 +0100 Subject: [PATCH] fix(commands): fix type check --- .../study/storage/variantstudy/variant_study_service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/antarest/study/storage/variantstudy/variant_study_service.py b/antarest/study/storage/variantstudy/variant_study_service.py index db61878252..412af1e561 100644 --- a/antarest/study/storage/variantstudy/variant_study_service.py +++ b/antarest/study/storage/variantstudy/variant_study_service.py @@ -201,6 +201,13 @@ def append_commands( command_objs = self._check_commands_validity(study_id, commands) validated_commands = transform_command_to_dto(command_objs, commands) first_index = len(study.commands) + + # type check in case user is None + if not params.user or not params.user.id: + user_id = None + else: + user_id = params.user.id + # noinspection PyArgumentList new_commands = [ CommandBlock( @@ -209,7 +216,7 @@ def append_commands( index=(first_index + i), version=command.version, study_version=str(command.study_version), - user_id=params.user.id, + user_id=user_id, updated_at=datetime.utcnow(), ) for i, command in enumerate(validated_commands)